Pat Shea
Pat Shea

Reputation: 11

Is there a way to view Stackdriver error reports without a standard GCP project?

My Google Apps script is failing occasionally during time-driven execution. It works perfectly fine when I run it from the Google App Scripts Editor.

I'd like to see the error reports for why it's failing. Nothing is showing up in the simple logs in the execution console. My project is not a GCP standard project so I can't view the logs on GCP.

I would prefer not to convert my project to a standard GCP project, as we are already running in production and I don't want to break anything.

Is there a way to view Stackdriver error reports without having a standard GCP project?

Upvotes: 1

Views: 103

Answers (1)

Alan Wells
Alan Wells

Reputation: 31300

As a test I created an Apps Script file, and created an error, then viewed the executions.

function myFunction() {
  var sum = valOne + 2; 
}

After running the above function from the code editor, I opened the Executions. In the Executions, there is a line with the status "Failed" and the error can be viewed by clicking the "Expand" icon.

View - Executions

If you use the "View" - "Stackdriver Logging" or "View" - "Stackdriver Error Reporting" menu items, you'll get a dialog box that shows:

View Stackdriver

So, there is no way to view the Stackdriver logs in the Google Cloud Platform for an Apps Script Project that is using the default Apps Script–managed Cloud Platform project.

But, if there is a failure, the error message is shown in the expanded view including the file name and line number where the error occurred. If you are catching the error, then the status in the executions will be "completed" not "Failed" but you can log an error and it will show up.

function myFunction() {
try{
  var sum = valOne + 2;
}catch(e) {
  console.error('myFunction failed: ' + e)
}
}

Executions Log for caught error:

Error Caught

Your issue is related to a time based trigger. If the time-based trigger isn't running it's function, there wouldn't be any error. You can't get an error from code that never ran.

Upvotes: 3

Related Questions