Skip to main content

@terascope/utils / errors

errors

Classes

ClassDescription
TSErrorA custom Error class with additional properties, like statusCode and fatalError

Interfaces

InterfaceDescription
ElasticsearchError-
TSErrorConfig-
TSErrorContextA simple object with any values

Functions

getErrorStatusCode()

getErrorStatusCode(err, config, defaultCode): number

Defined in: packages/utils/src/errors.ts:430

Parameters

ParameterTypeDefault value
errunknownundefined
configTSErrorConfig{}
defaultCodenumberDEFAULT_STATUS_CODE

Returns

number


getFullErrorStack()

getFullErrorStack(err): string

Defined in: packages/utils/src/errors.ts:165

Use following the chain of caused by stack of an error. Don't use this when logging the error, only when sending it

Parameters

ParameterType
errunknown

Returns

string


isElasticsearchError()

isElasticsearchError(err): err is ElasticsearchError

Defined in: packages/utils/src/errors.ts:394

Check is a elasticsearch error

Parameters

ParameterType
errunknown

Returns

err is ElasticsearchError


isError()

isError(err): err is Error

Defined in: packages/utils/src/errors.ts:381

Check if an input has an error compatible api

Parameters

ParameterType
errunknown

Returns

err is Error


isFatalError()

isFatalError(err): boolean

Defined in: packages/utils/src/errors.ts:372

Parameters

ParameterType
errunknown

Returns

boolean


isRetryableError()

isRetryableError(err): boolean

Defined in: packages/utils/src/errors.ts:376

Parameters

ParameterType
errunknown

Returns

boolean


isTSError()

isTSError(err): err is TSError

Defined in: packages/utils/src/errors.ts:386

Check is a TSError

Parameters

ParameterType
errunknown

Returns

err is TSError


logError()

logError(logger, err, ...messages): void

Defined in: packages/utils/src/errors.ts:232

Safely log an error (with the error first Logger syntax)

Parameters

ParameterType
loggerLogger
errunknown
...messagesany[]

Returns

void


parseError()

parseError(input, withStack): string

Defined in: packages/utils/src/errors.ts:270

parse input to get error message or stack

Parameters

ParameterTypeDefault value
inputunknownundefined
withStackbooleanfalse

Returns

string


parseErrorInfo()

parseErrorInfo(input, config): ErrorInfo

Defined in: packages/utils/src/errors.ts:177

parse error for info

Parameters

ParameterType
inputunknown
configTSErrorConfig

Returns

ErrorInfo


prefixErrorMsg()

prefixErrorMsg(input, prefix?, defaultMsg?): string

Defined in: packages/utils/src/errors.ts:360

Parameters

ParameterTypeDefault value
inputunknownundefined
prefix?stringundefined
defaultMsg?string'Unknown Error'

Returns

string


stripErrorMessage()

stripErrorMessage(error, reason, requireSafe): string

Defined in: packages/utils/src/errors.ts:451

Parameters

ParameterTypeDefault value
errorunknownundefined
reasonstringDEFAULT_ERR_MSG
requireSafebooleanfalse

Returns

string


toStatusErrorCode()

toStatusErrorCode(input): string

Defined in: packages/utils/src/errors.ts:328

Parameters

ParameterType
inputundefined | string

Returns

string