UNPKG

@roochnetwork/rooch-sdk

Version:
45 lines (44 loc) 1.7 kB
var ErrorCategory = /* @__PURE__ */ ((ErrorCategory2) => { ErrorCategory2[ErrorCategory2["INVALID_ARGUMENT"] = 1] = "INVALID_ARGUMENT"; ErrorCategory2[ErrorCategory2["OUT_OF_RANGE"] = 2] = "OUT_OF_RANGE"; ErrorCategory2[ErrorCategory2["INVALID_STATE"] = 3] = "INVALID_STATE"; ErrorCategory2[ErrorCategory2["UNAUTHENTICATED"] = 4] = "UNAUTHENTICATED"; ErrorCategory2[ErrorCategory2["PERMISSION_DENIED"] = 5] = "PERMISSION_DENIED"; ErrorCategory2[ErrorCategory2["NOT_FOUND"] = 6] = "NOT_FOUND"; ErrorCategory2[ErrorCategory2["ABORTED"] = 7] = "ABORTED"; ErrorCategory2[ErrorCategory2["ALREADY_EXISTS"] = 8] = "ALREADY_EXISTS"; ErrorCategory2[ErrorCategory2["RESOURCE_EXHAUSTED"] = 9] = "RESOURCE_EXHAUSTED"; ErrorCategory2[ErrorCategory2["CANCELLED"] = 10] = "CANCELLED"; ErrorCategory2[ErrorCategory2["INTERNAL"] = 11] = "INTERNAL"; ErrorCategory2[ErrorCategory2["NOT_IMPLEMENTED"] = 12] = "NOT_IMPLEMENTED"; ErrorCategory2[ErrorCategory2["UNAVAILABLE"] = 13] = "UNAVAILABLE"; return ErrorCategory2; })(ErrorCategory || {}); function parseRoochErrorCode(errorMessage) { if (!errorMessage) { return null; } const regex = /sub status (\d+)/; const match = errorMessage.match(regex); return match ? parseInt(match[1]) : null; } function parseRoochErrorSubStatus(errorMessage) { const errorCode = parseRoochErrorCode(errorMessage); if (!errorCode) { return null; } return { category: errorCode >> 16, reason: errorCode & 65535 }; } function getErrorCategoryName(code) { return ErrorCategory[code]; } export { ErrorCategory, getErrorCategoryName, parseRoochErrorCode, parseRoochErrorSubStatus }; //# sourceMappingURL=error.js.map