On Feb 29, 2008, at 7:04 AM, Benjamin Francisoud wrote:

About Internal Errors, do you consider such code to be part of them ?

public void something(Object object) {
   if (o == null) {
       throw new IllegalArgumentException("Object can't be null");
   }
   ...
}

class StateMachine {
   public void start() {...}
   public void end() {
       if (startCalled == false) {
           throw new IllegalStateException("You didn't call start()");
       }
   }
}
I would say these are internal errors. Anytime you can say to yourself, "this should never happen", it's an internal error. Another way to think of it is that you should only get that error if there is a bug in the code (e.g. someone called your function and passed a null reference, which your function explicitly said it didn't support). Errors that can be arrived at by user action or external conditions (parse error, file not found, etc.) are never internal errors.


About user errors, how should we handle them ?
The way I proposed in PIG-100 (1) ?

try {
   plan = parser.Parse();
} catch (ParseException e) {
   log.error(e.getMessage());
   log.debug(e);
}
After a user error control should return to whoever called PigServer, as pig can no longer do anything intelligent. It seems reasonable to let the error go through in this case, and let the caller of PigServer (whether that's Grunt or a user's code) deal with the exception.

Alan.

Reply via email to