Skip to content
This repository was archived by the owner on Aug 4, 2023. It is now read-only.
This repository was archived by the owner on Aug 4, 2023. It is now read-only.

Non-standard indentation and undefined catch scope #119

@robertosousa1

Description

@robertosousa1

In the file "lib/ndjson.js" the tryJSONStringify function is declared below your call, this causes an "Expected to return a value at the end of function 'tryJSONStringify' indentation conflict" and this function still has nothing defined in its catch scope.

I suggest implementing the following code:

'use strict'

const stringify = require('fast-safe-stringify')

function tryJSONStringify (obj) {
  try {
    return JSON.stringify(obj)
  } catch (e) {
    throw new Error('Error when running tryJSONStringify')
  }
}

exports.serialize = function serialize (obj) {
  const str = tryJSONStringify(obj) || stringify(obj)
  return str + '\n'
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-nodejsMake available for APM Agents project planning.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions