elastic / elastic/ecs-logging-nodejs

change formatError to not set `ecsFields.err` if the given `err` isn't an Error

Open
#66 1 comment 0 reactions 0 assignees View on GitHub
agent-nodejs
Dominant language
JavaScript
Stars
69
Forks
45
PR merge metrics
No merged PRs in 30d

Description

Currently `formatError` in the helpers package does this:

```js
function formatError (ecsFields, err) {
if (!(err instanceof Error)) {
ecsFields.err = err // <--- this line
return
}
```

I.e. if `err` is an Error, then it will fill in `ecsFields.error`. Otherwise it will set `ecsFields.err`. But "err" isn't a spec'd ECS field, so it shouldn't do that. It should be up to the callers to handle this. This would also better match formatHttpRequest and formatHttpResponse which do **not** set `ecsFields.req` or `.res` if they cannot process the given value.

This will be a breaking change.

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.