1.0.4 • Published 1 year ago

pursue-error v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

error-handler

npm version

In this project, we'll design an error log format as well as the protocol we'll use to communicate when our system encounters a problem. To manage error log messages, HTTP code, API error code, and trace, we developed the CustomError class. If you want to view a demonstration of what we've done, follow me:

try {
  ...
  if (!error)
    throw new NotFoundException(
      [Error message],
    )
  ...
} catch (error) {
  const trace = {
    source: "Function name (Ser)",
  }
  if (error instanceof CustomError) throw error.wrap(trace)
  throw new CustomError(error as Error).wrap(trace)
}

Example result

{
    "statusCode": 404,
    "timestamp": "2022-10-06T10:48:41.519Z",
    "path": "/entity/manage/1",
    "error": {
        "message": "Controller (Con): Service (Ser): Error message",
        "metadata": {
            "userId": "1"
        }
    }
}
1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago