add some changes in [ChopperException] class #661
add some changes in [ChopperException] class #661ahmedtalal wants to merge 1 commit intolejard-h:developfrom
Conversation
|
Hi, While I appreciate the effort, this is far too naive and needs a lot more work + the mandatory tests. There are a couple dozen of HTTP exceptions to handle and a simple enum just won't do. FYI I have created a Chopper plugin for Talker for pretty-printing errors Frezyx/talker#355 and it should come out in the next major release. This PR here could enhance the data it receives from the @Guldem care to throw an eye on this? |
| unknown, | ||
| } | ||
|
|
||
| extension ChopperExceptionTypeDescription on ChopperExceptionType { |
There was a problem hiding this comment.
With enhanced enums in Dart 3, creating extensions like these is no longer necessary. You can simply add a the method toPrettyDescription to the ChopperExceptionType enum.
| throw ChopperException( | ||
| request: request, | ||
| type: ChopperExceptionType.unknown, | ||
| error: |
There was a problem hiding this comment.
What's the benefit of all of this? The type is unknown and the error is basically the same.
| throw ChopperException( | ||
| request: chain.request, | ||
| type: ChopperExceptionType.unknown, | ||
| error: 'Unsupported response type: ${BodyType.runtimeType}', |
There was a problem hiding this comment.
Rather than writing a "pretty" message, this the ChopperException should consume a StackTrace
|
Extending the But I missing the point of providing Http information in the There is a chopper/chopper/lib/src/response.dart Line 86 in ea58a0e Still not sure if the package should do the error handling for http responses. |
Changed in ChopperException class to handle HTTP errors in a clear and structured way. This improves error reporting and makes it easier to manage failed responses gracefully.
Kindly consider accepting the request if it fits the direction of the project. 🙏