exception - Grails error handler always receives null pointer -
we have custom error controller gets called after of our errors. however, of our errors thrown end coming controller null pointers, though original error not null pointer. ideas? code below. bootstrap , urlmappings available if needed. thanks
error handler method
def handleerrors = {      def exception = request.exception.cause.class        if (exception)      {          exception ex = request.exception  //this exception npe             ... block of code throwing exception. did not have try catch in here, wanted add sure exception being thrown not npe. file not found exception.
try{         def writer = new filewriter( new file(filesavelocation));     }      catch ( ex)     {         throw(ex)     } edit: adding exception pushed exception handler
exception:org.codehaus.groovy.grails.web.errors.grailswrappedruntimeexception cause:org.springframework.web.util.nestedservletexception: request processing failed; nested exception java.lang.nullpointerexception 
it's not because you're referencing null inside error handler, , inadvertently throwing exception, again caught?
can try changing:
def exception = request.exception.cause.class   to
def exception = request?.exception?.cause?.class   
Comments
Post a Comment