Open lukechilds opened 6 years ago
we had making better error handling for 2.0 is it critically required to do now? it seems like a lot of work to find all possible errors and change them, in addition to the existing gui that is relying on the error text
Related: https://github.com/jl777/SuperNET/issues/594
is it critically required to do now?
No, not critical, just something we ran into and realised our error checks were likely to break in the future if the wording changed. Just wanted to track it here.
Currently, in the case of an error, mm returns an error property in the JSON with the value set as the error message.
This means theres no way to handle the errors without checking the entire string. And if the string ever changes in the future, all GUIs trying to handle that specific error will break because their string check will fail.
A better solution would be to return unique error codes along with each error.
Something like:
that way people can easily handle that specific error with:
instead of needing to do:
They can still access your error messages with
response.message
or supply their own.And you can update error messages without breaking any GUIs because everyone should be checking based on the codes.