GoogleCloudPlatform / GoogleCloudPlatform/stackdriver-errors-js

Problem doing manual error reporting

Open
#64 4 comments 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
360
Forks
54
PR merge metrics
No merged PRs in 30d

Description

Hi, I have code that does:

```
// In a promise `then` handler:
myRegister(new Error('some error'));
// ...
// Elsewhere in the code:
errorHandler.report(theNewError);
```

but the stackdriver API response is:

```
{
"error": {
"code": 400,
"message": "ReportedErrorEvent.context must contain a location unless `message` contain an exception or stacktrace.",
"status": "INVALID_ARGUMENT"
}
}
```

The request that is sent to stackdriver is:

```
{
"serviceContext": {"service": "webApp", "version": "whatever"},
"context": {
"user": "Joe User",
"httpRequest": {
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36",
"url": "http://localhost:3000/"
}
},
"message": "Error: {\"type\":\"An error during API handling\"}\n at then(function (/Users/murphyke/Documents/code/myapp/web/src/actions.js:224:0)"
};
```

What is the recommendation? Do I have to annotate the error object somehow?

Unhandled exceptions are reported correctly.

Using Chrome, btw.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.