user3284707
user3284707

Reputation: 3341

Log full exception on the client side from Google Apps Script back end

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'.

Upvotes: 1

Views: 384

Answers (1)

TheMaster
TheMaster

Reputation: 50443

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

console.error(error.message) 

Upvotes: 2

Related Questions