@gala-chain/chaincode ∙ API
API > BatchPartialSuccessRequiredError
Class: BatchPartialSuccessRequiredError
Contents
- Extends
- Constructors
- new BatchPartialSuccessRequiredError(index, error)
- Properties
- code
- key
- message
- name
- payload
- stack
- prepareStackTrace
- stackTraceLimit
- Methods
- andExec()
- logError()
- logWarn()
- map()
- matches()
- captureStackTrace()
- from()
- ignore()
- isChainError()
- map()
- matches()
- normalizedKey()
- recover()
- withCode()
Extends
ChainError
Constructors
new BatchPartialSuccessRequiredError(index, error)
new BatchPartialSuccessRequiredError(
index,error):BatchPartialSuccessRequiredError
Parameters
▪ index: number
▪ error: GalaChainErrorResponse\<unknown>
Overrides
ChainError.constructor
Source
chaincode/src/contracts/GalaContract.ts:55
Properties
code
readonlycode:ErrorCode
Overrides
ChainError.code
Source
chaincode/src/contracts/GalaContract.ts:53
key
readonlykey:Uppercase\<string>
An upper case string to be used as a key do diagnose where the error comes from and help with regular development. It should not be used by client integrating with the chain since we don't guarantee it won't change. It is generated from original error class name.
Inherited from
ChainError.key
Source
chain-api/src/utils/error.ts:54
message
message:
string
Inherited from
ChainError.message
Source
node_modules/typescript/lib/lib.es5.d.ts:1076
name
name:
string
Inherited from
ChainError.name
Source
node_modules/typescript/lib/lib.es5.d.ts:1075
payload
readonlypayload?:Record\<string,unknown>
Additional information to be used by
Inherited from
ChainError.payload
Source
chain-api/src/utils/error.ts:59
stack
stack?:
string
Inherited from
ChainError.stack
Source
node_modules/typescript/lib/lib.es5.d.ts:1077
prepareStackTrace
staticprepareStackTrace?: (err,stackTraces) =>any
Optional override for formatting stack traces
Parameters
▪ err: Error
▪ stackTraces: CallSite[]
Returns
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
ChainError.prepareStackTrace
Source
node_modules/@types/node/globals.d.ts:11
stackTraceLimit
staticstackTraceLimit:number
Inherited from
ChainError.stackTraceLimit
Source
node_modules/@types/node/globals.d.ts:13
Methods
andExec()
andExec(
fn):ChainError
Allows to execute function getting as a parameter the current error.
Parameters
▪ fn: (e) => void
Returns
Inherited from
ChainError.andExec
Example
Source
chain-api/src/utils/error.ts:115
logError()
logError(
logger):ChainError
Parameters
▪ logger: object
▪ logger.error
Inherited from
ChainError.logError
Source
chain-api/src/utils/error.ts:120
logWarn()
logWarn(
logger):ChainError
Parameters
▪ logger: object
▪ logger.warn
Inherited from
ChainError.logWarn
Source
chain-api/src/utils/error.ts:125
map()
map(
key,newError):ChainError
Maps ChainError to another chain error by error code if key param matches
current error code or current diagnostic key. Otherwise, returns original
error.
Useful in rethrowing an error or mapping an error to another one in catch clauses or catch methods in promises.
Parameters
▪ key: ErrorCode | ClassConstructor\<ChainError>
error code or error class to match
▪ newError: ChainError | (e) => ChainError
new error or a function to create the new error
Inherited from
ChainError.map
Source
chain-api/src/utils/error.ts:149
matches()
matches(
key):boolean
Parameters
▪ key: ErrorCode | ClassConstructor\<ChainError>
Inherited from
ChainError.matches
Source
chain-api/src/utils/error.ts:130
captureStackTrace()
staticcaptureStackTrace(targetObject,constructorOpt?):void
Create .stack property on a target object
Parameters
▪ targetObject: object
▪ constructorOpt?: Function
Inherited from
ChainError.captureStackTrace
Source
node_modules/@types/node/globals.d.ts:4
from()
staticfrom(e):ChainError
Parameters
▪ e: object & object
Inherited from
ChainError.from
Source
chain-api/src/utils/error.ts:169
ignore()
staticignore\<T>(e,key,defaultValue?):T
Recovers (mutes) ChainError to a specified return value or undefined.
Type parameters
▪ T = undefined
Parameters
▪ e: ChainError | object
▪ key: ErrorCode | ClassConstructor\<ChainError>
▪ defaultValue?: T
Returns
Inherited from
ChainError.ignore
Deprecated
Use ChainError.recover instead.
Source
chain-api/src/utils/error.ts:247
isChainError()
staticisChainError(e):e is ChainError
Parameters
▪ e: undefined | object
Inherited from
ChainError.isChainError
Source
chain-api/src/utils/error.ts:165
map()
staticmap(e,key,newError):ChainError
Maps ChainError to another chain error by error code, or returns original error if no error code matches, or returns default chain error if a given parameter is not a ChainError instance.
Useful in rethrowing an error or mapping an error to another one in catch clauses or catch methods in promises.
Parameters
▪ e: ChainError | object
original error
▪ key: ErrorCode | ClassConstructor\<ChainError>
error code or error class to match
▪ newError: ChainError | (e) => ChainError
new error or a function to create the new error
Inherited from
ChainError.map
Source
chain-api/src/utils/error.ts:192
matches()
staticmatches(e,key):boolean
Parameters
▪ e: ChainError | object
▪ key: ErrorCode | ClassConstructor\<ChainError>
Inherited from
ChainError.matches
Source
chain-api/src/utils/error.ts:173
normalizedKey()
staticnormalizedKey(fn):Uppercase\<string>
Parameters
▪ fn: string | Function
Inherited from
ChainError.normalizedKey
Source
chain-api/src/utils/error.ts:81
recover()
staticrecover\<T>(e,key,defaultValue?):T
Recovers (mutes) ChainError to a specified return value or undefined.
If the error is a ChainError and matches the error code, the error is recovered and the specified return value is returned. Otherwise, the error is re-thrown.
For instance when you want to get an object from chain, and instead of throwing a NOT_FOUND error, you want to return undefined:
If you want to return a default value instead of undefined, you can do:
Type parameters
▪ T = undefined
Parameters
▪ e: ChainError | object
original error
▪ key: ErrorCode | ClassConstructor\<ChainError>
error code or error class to match
▪ defaultValue?: T
value to be returned if error code matches
Inherited from
ChainError.recover
Source
chain-api/src/utils/error.ts:230
withCode()
staticwithCode(code):ClassConstructor\<ChainError>
Parameters
▪ code: ErrorCode
Inherited from
ChainError.withCode