I'm trying to report errors using the Google Cloud Error Reporting api. I want log them with their stackTrace. I do not want to use context.reportLocation
It is mentioned here that
message:string [Required] The error message. If no context.reportLocation is provided, the message must contain a header (typically consisting of the exception type name and an error message) and an exception stack trace in one of the supported programming languages and formats.
There is no example provided as to how to use the message
field instead of context.reportLocation
.
I tried getting the current stacktrace and stringifying it to pass to message field. But I kept getting the following error:
INVALID_ARGUMENT: ReportedErrorEvent.context must contain a location unless `message` contain an exception or stacktrace.
The actual error I want to report would be in string format coming in request payload.
Can anybody show an example with proper format for a JavaScript
?
My preferred approach is to:
report
ReportedErrorEvent
) and response typesIn this case ReportedErrorEvent
contains message
and this explains how to use it for various languages:
JavaScript: Must be the value of error.stack as returned by V8.