4

I'm just using NewRelic error trapping for my coldbox application. From OnException method, I'm just sending the error struct to log the error.

My code in onexception method

public function onException(event,rc,prc){
 NewRelic.logError( prc.exception.getExceptionStruct());
}

The logerror() method resides in NewRelic.cfc and contains the following code

 public boolean function logError(
  required struct exception
) {
  var cause = arguments.exception;
  var params = {  
    error_id =  createUUID(), 
    type: arguments.exception.type,
    message: arguments.exception.message
    };

    writeDump(this.newRelic);
    this.newRelic.noticeError(cause, params);abort;
    return true;
}

So while error, I'm gettig the following error.

The noticeError method was not found.

enter image description here

You can see that, the noticeError() method is there in the object, but it is overloaded with arguments.

I'm using the same code for NewRelic error trapping in another coldfusion project without any frameworks.

Calling error.cfm through Cferror tag, and the code in error.cfm as follows

<cfset Application.newRelic.logError( variables.error )>

And in NewRelic.cfc, the logerror() method contains the same code as in the coldbox application. But it is logging errors in NewRelic without any issues.

This is the method I need to notice errors and log it in NewRelic.

noticeError(java.lang.Throwable, java.util.Map)

So I just thought to get the classname of the first argument Cause through the following code from both applications within logError() in NewRelic.cfc, to get the difference.

writeDump(cause.getClass().getName());

I'm getting

coldfusion.runtime.ExceptionScope for Coldbox application and coldfusion.runtime.UndefinedVariableException for normal coldfusion application

The cause argument is not throwable from coldbox application. So how to get the original error struct from coldbox application? and make it throwable to fix the noticeError method was not found issue.

Rajesh Manilal
  • 1,104
  • 9
  • 20

1 Answers1

3

The change in the underlying class happens when ColdBox duplicates the error object with CFML's duplicate() method. I doubt that ColdFusion behavior is documented anywhere, but I don't see an easy way to get around it right now other than creating your own instance of a java.langException and populating it with the details of the original error.

If you want to modify the ColdBox core code, this happens here: https://github.com/ColdBox/coldbox-platform/blob/master/system/web/context/ExceptionBean.cfc#L43

I have entered this ticket for the ColdBox framework for us to review if we can stop duplicating the error object in future versions of the framework.

https://ortussolutions.atlassian.net/browse/COLDBOX-476

Update: Adam Cameron pointed out this ticket in the Adobe bug tracker that details this behavior in the engine. It was closed as "neverFix".

https://bugbase.adobe.com/index.cfm?event=bug&id=3976478

Brad Wood
  • 3,863
  • 16
  • 23
  • Thanks for the explanation and ticket creation with respect to the issue Let me try, if there is any other work around. – Rajesh Manilal Oct 06 '15 at 07:12
  • 1
    FYI: COLDBOX-476 has been fixed on the bleeding edge release of ColdBox and will go out in our 4.2.0 release once it is stable. This fix removes the duplicate() call and thus works around the ColdFusion behavior. – Brad Wood Oct 06 '15 at 22:09
  • I got solution for this issue on coldbox 4.2.0, and now my coldbox application logs error on Newrelic. – Rajesh Manilal Apr 07 '16 at 04:52