22
33namespace Redmine \Api ;
44
5- use Exception ;
5+ use Redmine \ Exception ;
66use Redmine \Exception \MissingParameterException ;
7+ use Redmine \Exception \SerializerException ;
78use Redmine \Serializer \PathSerializer ;
89use Redmine \Serializer \XmlSerializer ;
910
@@ -25,6 +26,8 @@ class Group extends AbstractApi
2526 *
2627 * @param array $params optional parameters to be passed to the api (offset, limit, ...)
2728 *
29+ * @throws SerializerException if response body could not be converted into array
30+ *
2831 * @return array list of groups found
2932 */
3033 final public function list (array $ params = []): array
@@ -43,13 +46,21 @@ final public function list(array $params = []): array
4346 *
4447 * @param array $params optional parameters to be passed to the api (offset, limit, ...)
4548 *
46- * @return array list of groups found
49+ * @return array|string|false list of groups found or error message or false
4750 */
4851 public function all (array $ params = [])
4952 {
5053 @trigger_error ('` ' .__METHOD__ .'()` is deprecated since v2.4.0, use ` ' .__CLASS__ .'::list()` instead. ' , E_USER_DEPRECATED );
5154
52- return $ this ->list ($ params );
55+ try {
56+ return $ this ->list ($ params );
57+ } catch (Exception $ e ) {
58+ if ($ this ->client ->getLastResponseBody () === '' ) {
59+ return false ;
60+ }
61+
62+ return $ e ->getMessage ();
63+ }
5364 }
5465
5566 /**
@@ -114,7 +125,7 @@ public function create(array $params = [])
114125 */
115126 public function update ($ id , array $ params = [])
116127 {
117- throw new Exception ('Not implemented ' );
128+ throw new \ Exception ('Not implemented ' );
118129 }
119130
120131 /**
0 commit comments