aino-komal / mvp4g

Automatically exported from code.google.com/p/mvp4g
0 stars 0 forks source link

Wrong error message on NullPointerException #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
On NullPointerException in the dispatch method of EventBus, the error
message is : 
"Event MyEvent doesn't exist. Have you forgotten to add it to your Mvp4g
configuration file?"

But if the NullPointerException is throw by the execute method, the error
message is not the appropriate.

A proposal to discuss : 

public void dispatch(Event e) {
  try {
    if ( commands.get(e.getType()) != null ) {
      commands.get(e.getType()).execute(e.getForm());
    }
    else {
      throw new Mvp4gException("Event " + e.getType() + " doesn't exist.
Have you forgotten to add it to your Mvp4g configuration file?");
    }
  }
  catch (ClassCastException er) {
    throw new Mvp4gException( "Class of the object sent with event" +
e.getType() + " is incorrect. It should be the same as the one configured
in the Mvp4g configuration file.");
  }
}

Original issue reported on code.google.com by jermarch...@gmail.com on 29 Jul 2009 at 9:40

GoogleCodeExporter commented 9 years ago
Same problem may occur with ClassCastException. However in this case, you may 
not be 
able to verify if it's thrown inside library code or developer code.

Original comment by plcoir...@gmail.com on 7 Aug 2009 at 11:18

GoogleCodeExporter commented 9 years ago
issue 2: before sending a Mvp4gException in case of NullPointerException and 
ClassCastException, verify if it has been thrown by the
library classes thanks to the stack trace of the exception.

Original comment by plcoir...@gmail.com on 10 Aug 2009 at 11:05