Skip to main content
Version: Next

ErrorTracker

This class tracks errors and computes a summary of information like:

  • where the errors happened
  • what the error names are
  • what the error codes are
  • what is the general error message

This is extremely useful when there are dynamic error messages, such as argument validation.

Since the structure of the tracker.result object differs when using different options, it's typed as Record<string, unknown>. The most deep object has a count property, which is a number.

It's possible to get the total amount of errors via the tracker.total property.

Index

Constructors

constructor

Properties

optionalerrorSnapshotter

errorSnapshotter?: ErrorSnapshotter

result

result: Record<string, unknown>

total

total: number

Methods

add

addAsync

  • This method is async, because it captures a snapshot of the error context. We added this new method to avoid breaking changes.


    Parameters

    Returns Promise<void>

captureSnapshot

getMostPopularErrors

  • getMostPopularErrors(count: number): [number, string[]][]
  • Parameters

    • count: number

    Returns [number, string[]][]

getUniqueErrorCount

  • getUniqueErrorCount(): number
  • Returns number

reset

  • reset(): void
  • Returns void