MCPcopy
hub / github.com/slackapi/node-slack-sdk / errorWithCode

Function errorWithCode

packages/web-api/src/errors.ts:52–57  ·  view source on GitHub ↗

* Factory for producing a CodedError from a generic error

(error: Error, code: ErrorCode)

Source from the content-addressed store, hash-verified

50 * Factory for producing a {@link CodedError} from a generic error
51 */
52function errorWithCode(error: Error, code: ErrorCode): CodedError {
53 // NOTE: might be able to return something more specific than a CodedError with conditional typing
54 const codedError = error as Partial<CodedError>;
55 codedError.code = code;
56 return codedError as CodedError;
57}
58
59/**
60 * A factory to create WebAPIRequestError objects

Callers 4

requestErrorWithOriginalFunction · 0.70
httpErrorFromResponseFunction · 0.70
platformErrorFromResultFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected