November 2018
Intermediate to advanced
388 pages
9h 5m
English
We have already seen how the dao layer throws the exception, and how the controller layer handles that exception and returns a proper error message to the requesting client. Let's quickly see the details of the exception-handling code.
We can create our own exception class, which we can use in our business cases as appropriate.
To create an exception class, we need to extend either the Exception or Throwable class, shown as follows:
class IdentityNotFoundException(message: String) : Exception(message) {}
Alternatively, we can use the following code:
class IdentityNotFoundException(message: String) : Throwable(message) {}
As shown in the preceding code, the custom exception class has to be inherited from either the Throwable ...
Read now
Unlock full access