File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,7 @@ class CoapClient extends ProtocolClient {
193
193
}
194
194
195
195
coapClient.close ();
196
+ response.checkResponseCode ();
196
197
return response.content;
197
198
}
198
199
Original file line number Diff line number Diff line change @@ -153,6 +153,18 @@ extension ResponseExtension on CoapResponse {
153
153
return Content (_contentType, _payloadStream);
154
154
}
155
155
156
+ /// Checks the [code] of this [CoapResponse] and throws an [Exception] if it
157
+ /// should indicate an error.
158
+ void checkResponseCode () {
159
+ if (code.isServerError) {
160
+ throw CoapServerErrorException (this );
161
+ }
162
+
163
+ if (code.isErrorResponse) {
164
+ throw CoapClientErrorException (this );
165
+ }
166
+ }
167
+
156
168
/// Validates the payload and returns a serialized ACE creation hint if
157
169
/// successful.
158
170
AuthServerRequestCreationHint ? get creationHint {
You can’t perform that action at this time.
0 commit comments