Skip to main content
17-Peridot
October 2, 2020
Solved

Get the call stack of the javascript service

  • October 2, 2020
  • 1 reply
  • 1320 views

Hi,

 

I want to all of the service use a unified way of raise error message ,  so the the service will call the wrapped service like RaiseError service instead of javascript statement "throw new error" when raising error.   

The problem is that you can only find the line number of RaiseError service in the application log for any service while I need the original position where RaiseError is called .   

So can I get the call stack with information of line number so that I can log a more specified error info ? 

 

Regards,

Sean

Best answer by nmilleson

@seanccc ,

 

The JavaScript Error object has lineNumber and stack that you can access in your catch statement:

 

try{
 //some code here
}
catch(err) {
 logger.warn(err.lineNumber + " " + err.stack);
}

 

 

1 reply

nmilleson17-PeridotAnswer
17-Peridot
October 2, 2020

@seanccc ,

 

The JavaScript Error object has lineNumber and stack that you can access in your catch statement:

 

try{
 //some code here
}
catch(err) {
 logger.warn(err.lineNumber + " " + err.stack);
}