1

I am trying to debug an add on which has been published, however the exception I get back from the GAS back end does not give me much information other than the line and function it was thrown from.

Is there a way to get a more detailed error description passed back to the client?

In my example I am calling the function testException, all it currently does is throw an exception.

CLIENT SIDE CODE

google.script.run
    .withSuccessHandler(result => console.log(result))
    .withFailureHandler(error => console.error(error))
    .testException();

SERVER SIDE CODE

function testException() {
    throw new Error('Test message to show on client side');
}

All the information I get back is the following:

at testException (code:196) (Test Add On) 42bb9613-6241-4ab9-b39f-01fe5c56b060

If possible I would like to get the same level of detail as the stackdriver logging. Or even just the error message 'Test message to show on client side'.

Rubén
  • 34,714
  • 9
  • 70
  • 166
user3284707
  • 3,033
  • 3
  • 35
  • 69
  • Have you tried `console.error(error.message)` – TheMaster May 21 '19 at 15:45
  • Possible duplicate of [How to get JavaScript caller function line number? How to get JavaScript caller source URL?](https://stackoverflow.com/questions/1340872/how-to-get-javascript-caller-function-line-number-how-to-get-javascript-caller) – Rubén May 21 '19 at 15:48
  • error.message worked... I thought this would have been shown as part of the error object so didn't think to try it, thanks very much. – user3284707 May 21 '19 at 15:49

1 Answers1

2

You can access the message inside the js error object using:

console.error(error.message) 
TheMaster
  • 45,448
  • 6
  • 62
  • 85