Wiki

Clone wiki

XALPI / boRuntimeExceptions

boRuntimeExceptions

One less than convenient issue with the API is the number of boRuntimeExceptions being thrown for almost every method call. As a matter of convenience (and this is a personal choice, so bear with it) I decided to make almost every method not throw the exception (the underlying implementations catch the exceptions and LOG them under the WARNING level (returning null when a return value is expected).

From the BaseModel javadoc you can check that now only the update/destroy methods throw boRuntimeExceptions

#!java

public void update() throws boRuntimeException;
public void destroy() throws boRuntimeException;

What about events in attributes that throw boRuntimeExceptions because they save/destroy objects?

You have a point, but like I said... 99% of the time, it's more convenient. A solution is to extend java.lang.RuntimeException and throw it up, checking for it whenever you need. Think of it the same way you would think for Long.parseLong(String s) method, which throws a NumberFormatException that you don't have to necessarily catch.

Updated