UNPKG

callback-utility

Version:
60 lines 3.7 kB
export var CBExceptions; (function (CBExceptions) { CBExceptions[CBExceptions["NoError"] = 0] = "NoError"; CBExceptions[CBExceptions["InternalError"] = 1] = "InternalError"; CBExceptions[CBExceptions["ExecutionException"] = 2] = "ExecutionException"; CBExceptions[CBExceptions["ResultAlreadySet"] = 3] = "ResultAlreadySet"; CBExceptions[CBExceptions["TokenInFirstCall"] = 4] = "TokenInFirstCall"; CBExceptions[CBExceptions["TokenInParallelCall"] = 5] = "TokenInParallelCall"; CBExceptions[CBExceptions["InvalidTokenResult"] = 6] = "InvalidTokenResult"; CBExceptions[CBExceptions["InvalidStructToExecute"] = 7] = "InvalidStructToExecute"; CBExceptions[CBExceptions["NoStatsGathered"] = 8] = "NoStatsGathered"; CBExceptions[CBExceptions["ResultAlreadySetForAlias"] = 9] = "ResultAlreadySetForAlias"; })(CBExceptions || (CBExceptions = {})); const ERRORS_DETAILS = { [CBExceptions.NoError]: { message: "No error" }, [CBExceptions.InternalError]: { message: "Internal error ocurred", explanation: "Something unexpected happened. Check baseException property to get more info" }, [CBExceptions.ExecutionException]: { message: "Execution exception", explanation: "An exception was thrown during the execution of call struct" }, [CBExceptions.ResultAlreadySet]: { message: "Result was set more than once", explanation: "A callback function was invoked more than once, creating double results for a call" }, [CBExceptions.TokenInFirstCall]: { message: "Invalid use of token in first call", explanation: "You've tried to use a token to access previous result in the first call, which has no previous result to access" }, [CBExceptions.TokenInParallelCall]: { message: "Invalid use of token in parallel call", explanation: "You've tried to use a token to access previous result in a parallel call, which is invalid" }, [CBExceptions.InvalidTokenResult]: { message: "Invalid use of token result", explanation: "You've tried to use a token to access previous result, but previous call has not such result in array" }, [CBExceptions.InvalidStructToExecute]: { message: "Execution struct must be parallel or sequential", explanation: "You've tried execute a struct that is not parallel nor sequential, thus invalid" }, [CBExceptions.NoStatsGathered]: { message: "No stats were gathered", explanation: "You've tried access stats for a call, but executed struct with 'Stats=false'" }, [CBExceptions.ResultAlreadySetForAlias]: { message: "Result was set more than once for this alias", explanation: "A result has already been set for this alias" }, }; export class CBException extends Error { constructor(p_ErrorNumber, p_DorE, p_Stack, p_BaseException) { let structDetails, objBaseException; if (p_DorE instanceof Error) { objBaseException = p_DorE; } else { structDetails = p_DorE; objBaseException = p_BaseException; } super(ERRORS_DETAILS[p_ErrorNumber].message); this.errorNumber = p_ErrorNumber; if (p_Stack) this.stack = p_Stack; else delete this.stack; if (structDetails) this.details = structDetails; else delete this.details; if (objBaseException) this.baseException = objBaseException; else delete this.baseException; if (ERRORS_DETAILS[p_ErrorNumber].explanation) this.explanation = ERRORS_DETAILS[p_ErrorNumber].explanation; else delete this.explanation; } errorNumber; details; baseException; explanation; } //# sourceMappingURL=exception.js.map