Skip to content

Commit 31cc980

Browse files
committed
fix: safely handle null/non-string errorResponse code
1 parent 31bfb6d commit 31cc980

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/dart/lib/src/objects/response/parse_exception_response.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ ParseResponse buildParseResponseWithException(Exception exception) {
1111
final errorMessage =
1212
errorResponse['error']?.toString() ?? exception.response?.statusMessage;
1313

14+
final String? codeString = errorResponse['code']?.toString();
1415
final errorCode =
15-
int.tryParse(errorResponse['code']) ?? exception.response?.statusCode;
16+
int.tryParse(codeString ?? '') ?? exception.response?.statusCode;
1617

1718
return ParseResponse(
1819
error: ParseError(

0 commit comments

Comments
 (0)