Replies: 4 comments 5 replies
-
Totally agree the exception handling is not ideal currently. If you can outline a proposal I'd appreciate it! |
Beta Was this translation helpful? Give feedback.
-
Ok, here's my initial thoughts: All of the requests have two checked exceptions. One is ConfigurationException, one is UserException. ConfigurationException covers anything that only a developer would be expected to resolve (e.g. missing api keys, bad URL, etc). UserException would cover anything a user would be expected to resolve (e.g. existing user, password problem, etc). The existing exceptions would get folded into one of these two exceptions, with perhaps an enum to distinguish between types instead of different classes. I think there are some error conditions that don't really map to existing exceptions right now, e.g. user already registered. I think the only way to distinguish between some of these right now is by matching text to the message back from the server. I think part of the idea would be to try to do a best case match between the exception and the content from the server to set the enum, if nothing matches it either falls back on a generic User exception or a Configuration exception. I just saw you added a base GoTrueException. I would make both Configuration and User descend from those. :) I'd also move Response, Content, etc up to GoTrueException as nullable. The idea is that a user could either catch GoTrueException (e.g. for demos just catch and dump the exception to a log), but for a production app the developer can catch user and configuration and present the info as needed (e.g. for User it's "fix X" and for Configuration it's "Developer needs to fix" |
Beta Was this translation helpful? Give feedback.
-
I'm thinking it would be Good For Me(tm) to submit some changes as PRs. Tho, I gotta ask... Is that the preferred style for C#? ;) |
Beta Was this translation helpful? Give feedback.
-
Resolved over several PRs including #57 Woot! |
Beta Was this translation helpful? Give feedback.
-
I'm noticing a few things about the exception handling, had some Qs/thoughts:
There are a number of unchecked exceptions with no base class for various requests (I'm mostly focusing on signing up & signing in via anon key client). This is making it a bit hard to work with, as I have to make sure I go through and capture everything.
I think what I'd like would be for requests to throw two kinds of checked exception, one intended for user-level problems (e.g. existing account, invalid email/pass) and one intended for developers (e.g. bad anon key, bad url, etc). That way I could have two exceptions to track (which my IDE can automatically generate catches for) instead of the current set.
I'm also noticing that there is some inconsistency in how the exceptions are caught/thrown - for example, some of the user errors appear to be hidden in a BadRequest.
I guess the question is how critical are the current exceptions vs a rework to make them easier to deal with? Does this make sense? Should I go ahead and send a PR proposal, or...?
Beta Was this translation helpful? Give feedback.
All reactions