@@ -54,10 +54,10 @@ public function dataGet($url, $headers = null, $options = array()) {
54
54
$ response = json_decode ($ e ->getResponse ()->getBody (), true );
55
55
$ msg = isset ($ response ['message ' ]) ? $ response ['message ' ] : 'Unknown error ' ;
56
56
if ($ e ->getResponse ()->getStatusCode () == 503 ) {
57
- throw new NitrapiMaintenanceException ($ msg );
57
+ throw new NitrapiMaintenanceException ();
58
58
}
59
59
if ($ e ->getResponse ()->getStatusCode () == 428 ) {
60
- throw new NitrapiConcurrencyException ($ msg );
60
+ throw new NitrapiConcurrencyException ();
61
61
}
62
62
throw new NitrapiHttpErrorException ($ msg );
63
63
}
@@ -94,10 +94,10 @@ public function dataPost($url, $body = null, $headers = null, $options = array()
94
94
$ response = json_decode ($ e ->getResponse ()->getBody (), true );
95
95
$ msg = isset ($ response ['message ' ]) ? $ response ['message ' ] : 'Unknown error ' ;
96
96
if ($ e ->getResponse ()->getStatusCode () == 503 ) {
97
- throw new NitrapiMaintenanceException ($ msg );
97
+ throw new NitrapiMaintenanceException ();
98
98
}
99
99
if ($ e ->getResponse ()->getStatusCode () == 428 ) {
100
- throw new NitrapiConcurrencyException ($ msg );
100
+ throw new NitrapiConcurrencyException ();
101
101
}
102
102
throw new NitrapiHttpErrorException ($ msg );
103
103
}
@@ -140,10 +140,10 @@ public function dataDelete($url, $body = null, $headers = null, $options = array
140
140
$ response = json_decode ($ e ->getResponse ()->getBody (), true );
141
141
$ msg = isset ($ response ['message ' ]) ? $ response ['message ' ] : 'Unknown error ' ;
142
142
if ($ e ->getResponse ()->getStatusCode () == 503 ) {
143
- throw new NitrapiMaintenanceException ($ msg );
143
+ throw new NitrapiMaintenanceException ();
144
144
}
145
145
if ($ e ->getResponse ()->getStatusCode () == 428 ) {
146
- throw new NitrapiConcurrencyException ($ msg );
146
+ throw new NitrapiConcurrencyException ();
147
147
}
148
148
throw new NitrapiHttpErrorException ($ msg );
149
149
}
@@ -154,11 +154,7 @@ public function dataDelete($url, $body = null, $headers = null, $options = array
154
154
}
155
155
156
156
protected function checkErrors (Response $ response , $ responseCode = 200 ) {
157
- $ json = @json_decode ($ response ->getBody (), true );
158
-
159
- if (is_array ($ json ) && isset ($ json ['status ' ]) && $ json ['status ' ] == "error " ) {
160
- throw new NitrapiHttpErrorException ($ json ["message " ]);
161
- }
157
+ $ json = json_decode ($ response ->getBody (), true );
162
158
163
159
$ allowedPorts = array ();
164
160
$ allowedPorts [] = $ responseCode ;
@@ -169,5 +165,9 @@ protected function checkErrors(Response $response, $responseCode = 200) {
169
165
if (!in_array ($ response ->getStatusCode (), $ allowedPorts )) {
170
166
throw new NitrapiHttpErrorException ("Invalid http status code " . $ response ->getStatusCode ());
171
167
}
168
+
169
+ if (isset ($ json ['status ' ]) && $ json ['status ' ] == "error " ) {
170
+ throw new NitrapiHttpErrorException ("Got Error from API " . $ json ["message " ]);
171
+ }
172
172
}
173
173
}
0 commit comments