You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class Controller {
public void save() throws InvalidObjectException {
callExternalServiceThatThrowsException();
}
}
The fact that it throws InvalidObjectException is not important
what is important is that it throws an exception when some error occurs
in the external service, beit a ReST API or what.
This seems totally reasonable, and since the controller should be completely
agnostic of the view, throwing an exception and having it bubble up to
an appropriate error handler seems valuable. At the moment, I have no way
of handling the error.
I want to be able to pass this error up to the view so that it can handle
it in a graceful manner. Such as:
public void handleError( Throwable t ) {
displayErrorMessage("I got an error!", t);
}
I currently can do this, sort of, by calling an reportError method or
something on the model, but that tends to clog up my model with a lot of
error reporting code (it has to hold onto the error for just long enough
for the view to respond to it).
This is similar to the callback systems from jQuery $.ajax method:
I have a controller with the following signature:
The fact that it throws
InvalidObjectException
is not importantwhat is important is that it throws an exception when some error occurs
in the external service, beit a ReST API or what.
This seems totally reasonable, and since the controller should be completely
agnostic of the view, throwing an exception and having it bubble up to
an appropriate error handler seems valuable. At the moment, I have no way
of handling the error.
I want to be able to pass this error up to the view so that it can handle
it in a graceful manner. Such as:
I currently can do this, sort of, by calling an
reportError
method orsomething on the model, but that tends to clog up my model with a lot of
error reporting code (it has to hold onto the error for just long enough
for the view to respond to it).
This is similar to the callback systems from jQuery $.ajax method:
I could forsee this looking like the following in cinch:
Is there potentially a better way to solve this?
The text was updated successfully, but these errors were encountered: