convertCodeToException static method
Converts an error code to its corresponding Exception.
This method iterates over the exceptions list and returns the exception that matches the provided error code.
If no match is found, it returns an UnknownErrorException.
@param errorCode The error code to convert to an Exception.
@return The Exception that corresponds to the provided error code.
Implementation
static Exception convertCodeToException(String errorCode) {
for (int x = 0; x < exceptions.length; x++) {
if (exceptions[x].toCode() == errorCode) {
return exceptions[x];
}
}
return UnknownErrorException();
}