So I am trying to create a great UX. To do that I need to communicate to the user what exactly went wrong. The only way I believe this can be done, is by creating specific error messages with actionable steps to remedy the situation.
This is not provided by the localises messages delivered by an NSError. I find the error messages to be too generic. This is especially true when the error comes with a nested "NSUnderlyingError". Furthermore, in my experience they never suggest how to fix the error.
So, how to best handle that?
Right now, I have chosen to return my own errors - which are determined as follows:
So, my questions are:
This is not provided by the localises messages delivered by an NSError. I find the error messages to be too generic. This is especially true when the error comes with a nested "NSUnderlyingError". Furthermore, in my experience they never suggest how to fix the error.
So, how to best handle that?
Right now, I have chosen to return my own errors - which are determined as follows:
Cast the error to NSError.
Check the error domain and code.
For certain domains (and codes) I check for an underlaying errors and codes, and if one is found I return an error with a precise error message.
If no underlaying error is found, I return the more generic error found in step 2.
So, my questions are:
should I rely on the error codes in this way?
is this a good approach?
what would be a better approach?