Version 4.10.0

hirondelle.web4j.model
Class ModelCtorException

Object
  extended by Throwable
      extended by Exception
          extended by hirondelle.web4j.model.AppException
              extended by hirondelle.web4j.model.ModelCtorException
All Implemented Interfaces:
MessageList, Serializable

public final class ModelCtorException
extends AppException

Thrown when a Model Object (MO) cannot be constructed because of invalid constructor arguments.

Arguments to a MO constructor have two sources: the end user and the the database. In both cases, errors in the values of these arguments are outside the immediate control of the application. Hence, MO constructors should throw a checked exception - (ModelCtorException).

Using a checked exception has the advantage that it cannot be ignored by the caller. Example use case:

  //a Model Object constructor 
  Blah(String aText, int aID) throws ModelCtorException {
    //check validity of all params.
    //if one or more params is invalid, throw a ModelCtorException.
    //for each invalid param, add a corresponding error message to 
    //ModelCtorException. 
  }

  //call the Model Object constructor 
  try {
    Blah blah = new Blah(text, id);
  }
  catch(ModelCtorException ex){
    //place the exception in scope, for subsequent 
    //display to the user in a JSP
  }

In the case of an error, the problem arises of how to redisplay the original, erroneous user input. The Populate tag accomplishes this in an elegant manner, simply by recycling the original request parameters.

See Also:
Serialized Form

Constructor Summary
ModelCtorException()
           
 
Method Summary
 
Methods inherited from class hirondelle.web4j.model.AppException
add, add, add, getMessages, isEmpty, isNotEmpty, toString
 
Methods inherited from class Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModelCtorException

public ModelCtorException()

Version 4.10.0

Copyright Hirondelle Systems. Published October 19, 2013 - User Guide - All Docs.