0

In my org I have managed package with namespace DeltaLKU which contains apex classes & components for the application that we are developing and I have installed another third party managed package called Nebula which has namespace Nebula for logging the errors and exceptions.

Here is the link for Nebula library that we are using: https://github.com/jongpie/NebulaLogger

I am using methods from Nebula package to log error which occur in our managed package (DeltaLKU). A typical code block to log errors in the apex class (LKU_AppController) from our managed package (DeltaLKU) will look like as below:

LKU_AppController.cls

try {
  // some code which will throw error
} catch (Exception e) {
  Nebula.logger.error(e.getMessage(), e); // nebula's method signature for creating log: error(String message, Exception apexException)
  Nebula.saveLog();
}

So as per the above code when there is some error in this try-catch block, nebula will create a log record which will have error message section and stack trace section (screenshots below).

In developer sandbox (where our code is non packaged)

The error message and stack trace is shown properly like below:

enter image description here

In production org (where our code is packaged with namespace DeltaLKU)

The error message is shown as expected but stack trace is not shown properly, instead only the namespace is available in stack trace field like below:

enter image description here

Can any one please suggest what can be done to make the stack trace string available to Nebula package for the error occurring in our managed package DeltaLKU?

1
  • Have you found your solution, I would suggest using LMS & passing the valuable string representation of what you need to forward. LMS uses JSON.stringify() and JSON.parse() to pass data Commented May 20 at 13:08

1 Answer 1

0

I have a few suggestions.

  1. Maybe rather than pass e.GetMessage() directly to Nebula logger in the first paramNebula.logger.error(string message,object errorObject); , put that in a string variable instead , and pass that value instead. that way you are passing by a primitive value and not by a reference to the exception object.
  2. Similar to one but let the exception message be a global property and also live in some sort of wrapper class that is marked as GLOBAL (so that its code can be accessed outside its namespace) something like this , you can then use a builder to set the exception error message this.errormessage = errormessage then call another method to register the Exception. something like new LKU_Logging().withMessage(string errormessage).log(Exception e); in the log method you can then make the call directly to Nebula like this Nebula.logger.error(this.errorMessage, e);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .