Marking a Transaction as an Error Transaction

An error transaction is one in which an exception occurred. It is reported as an error transaction and not as a slow, very slow or stalled transaction, even if the transaction in which the error occurred was also slow or stalled.

To attach a JavaScript error object to a transaction using the Node.js APIs do one of the following:

  • Use trx.markError() passing in the JavaScript error object.
  • Attach the error object to the HTTP response associated with the transaction as response.error.

When an error is marked, the status code defaults to 500, unless you set it using one of the following techniques:

  • Use trx.markError() passing in the JavaScript error object and the optional status code.
  • Set the statusCode property in the error object passed to trx.markError() as error.StatusCode .
  • Set the statusCode property on the response.error object as response.error.StatusCode.