API Docs for: 0.8.0
Show:

ErrorsOverTime Class

Wraps up code that allows developers the ability to time box errors. In some instances errors will occur. It is only when a certain number of those errors occur within a given time span that it is recognized that recovery is improbable. When the threshold is broken the code allows you to throw an error that represents all others that contributed to the threshold breach.

Constructor

ErrorsOverTime

(
  • errorSpan
  • errorThreshold
  • [prefix]
)

Parameters:

  • errorSpan Integer

    The upper bound on the number of errors that can occur within the provided time frame before it is determined that recovery is not possible.

  • errorThreshold Integer

    The upper bound on the amount of time, in milliseconds, that errors can occur in before it is determined that recovery is not possible.

  • [prefix] String optional

    The prefix to any error message that is generated by the instance

Methods

createError

(
  • errors
  • prefix
)
Error static

Creates an Error that represents all of the errors that triggered the threshold breach.

Parameters:

  • errors Array

    The array of errors that will be represented by one wrapper error

  • prefix String

    The error message text that will come first

Returns:

Error:

errorOccurred

(
  • The
)
Boolean

Adds an error into the calculation to determine if too many errors have occurred within a particular time span.

Parameters:

  • The Error

    error that occurred

Returns:

Boolean:

TRUE if threshold is in tact, FALSE if not

generateError

(
  • errors
  • prefix
)
static

Generates and throws an Error that represents all of the errors that triggered the threshold breach.

Parameters:

  • errors Array

    The array of errors that will be represented by one wrapper error

  • prefix String

    The error message text that will come first

getRange

() Integer

Gets the time span over which the current set of errors has occurred

Returns:

Integer:

The number of milliseconds over which the last "n" number of errors have occurred where "n" is the value is between 0 and the value of the errorSpan property inclusive.

isWithinLimits

() Boolean

Determines if the errors that have occurred are within the acceptable tolerance.

Returns:

Boolean:

TRUE if threshold in tact, FALSE if not

throwIfOutOfBounds

(
  • The
  • prefix
)
Boolean

Adds an error into the calculation to determine if too many errors have occurred within a particular time span. If the threshold has been broken an error is thrown.

Parameters:

  • The Error

    error that occurred

  • prefix String

    The error message text that will come first

Returns:

Boolean:

TRUE if threshold is in tact, FALSE if not

Properties

errors

Array

The list of errors that will be used to determin if too many errors have occurred within a given time frame.

errorSpan

Integer

The upper bound on the number of errors that can occur within the provided time frame before it is determined that recovery is not possible.

errorThreshold

Integer

The upper bound on the amount of time, in milliseconds, that errors can occur in before it is determined that recovery is not possible.

prefix

String

The prefix to any error message that is generated by the instance

totalErrorCnt

Integer

The total number of errors that have occurred