IbrahimDevp / flutter_auth

0 stars 0 forks source link

Handling error responses #6

Open adnsawas opened 1 year ago

adnsawas commented 1 year ago

https://github.com/ikema77/flutter_auth/blob/0b86b7d22c968fdd363c173abcfbd6dd2510f919/lib/providers/auth.dart#L40-L41

Throwing an exception depending on value type might not be optimal. Checking response.statusCode could be a more reliable approach

Another more reliable approach is to agree with your back-end developer to include a new object with every request. This object indicates whether this response is a successful or failed response. This way you can create a global utility function that knows how to handle all errors.

mutairibassam commented 1 year ago

@ikema77 please let me know if you need any modification from backend side?