Skip to content

Commit

Permalink
fix: add fatal apiresponse [CLERK_SDK #66]
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyford committed Dec 20, 2024
1 parent b0d30be commit 5cd7455
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/clerk_auth/lib/src/clerk_api/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,8 @@ class Api with Logging {
return _processResponse(resp);
} catch (error, stacktrace) {
logSevere('Error during fetch', error, stacktrace);
return ApiResponse(
status: HttpStatus.internalServerError,
errors: [ApiError(message: error.toString())],
return ApiResponse.fatal(
error: ApiError(message: error.toString()),
);
}
}
Expand Down Expand Up @@ -572,9 +571,8 @@ class Api with Logging {
return _processResponse(resp);
} catch (error, stacktrace) {
logSevere('Error during fetch', error, stacktrace);
return ApiResponse(
status: HttpStatus.internalServerError,
errors: [ApiError(message: error.toString())],
return ApiResponse.fatal(
error: ApiError(message: error.toString()),
);
}
}
Expand Down
7 changes: 7 additions & 0 deletions packages/clerk_auth/lib/src/models/api_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ class ApiResponse {
this.client,
});

/// Constructs an [ApiResponse] for situations in which the backend
/// failed to respond
ApiResponse.fatal({required ApiError error})
: status = 0,
errors = [error],
client = null;

/// http status
final int status;

Expand Down

0 comments on commit 5cd7455

Please sign in to comment.