@polygonlabs/servercore 1.0.0-dev.35 → 1.0.0-dev.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,7 +49,9 @@ class BadRequestError extends ApiError {
|
|
49
49
|
}
|
50
50
|
class NotFoundError extends ApiError {
|
51
51
|
constructor(message, entity = "Path", identifier, context = {}, origin = "api_errors") {
|
52
|
-
message
|
52
|
+
if (!message) {
|
53
|
+
message = identifier ? `${entity} with identifier ${identifier} not found` : `${entity} not found`;
|
54
|
+
}
|
53
55
|
super(message, {
|
54
56
|
name: "NOT_FOUND",
|
55
57
|
code: errorCodes.api.NOT_FOUND,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/errors/api_errors.ts"],"sourcesContent":["import { BaseError } from \"./base_error\";\nimport { errorCodes } from \"../constants\";\n\nexport class ApiError extends BaseError {\n constructor(\n message: string,\n {\n name = \"INTERNAL_SERVER_ERROR\",\n code = errorCodes.api.INTERNAL_SERVER_ERROR,\n isFatal = false,\n origin = \"api_errors\",\n context = {},\n }: {\n name?: string;\n code?: number;\n isFatal?: boolean;\n origin?: string;\n context?: Record<string, any>;\n } = {}\n ) {\n super(name, code, message, isFatal, origin, context);\n Error.captureStackTrace(this, this.constructor);\n }\n}\n\nexport class UnauthorizedError extends ApiError {\n constructor(\n message: string = \"Invalid auth credentials\",\n context: Record<string, any> = {},\n origin: string = \"api_errors\"\n ) {\n super(message, {\n name: \"UNAUTHORIZED\",\n code: errorCodes.api.UNAUTHORIZED,\n isFatal: false,\n origin,\n context,\n });\n }\n}\n\nexport class ForbiddenError extends ApiError {\n constructor(\n message: string = \"You do not have permission to perform this action\",\n context: Record<string, any> = {},\n origin: string = \"api_errors\"\n ) {\n super(message, {\n name: \"FORBIDDEN\",\n code: errorCodes.api.FORBIDDEN,\n isFatal: false,\n origin,\n context,\n });\n }\n}\n\nexport class BadRequestError extends ApiError {\n public readonly validationErrors: Record<string, string[]>;\n\n constructor(\n message: string = \"Malformed or invalid request\",\n validationErrors: Record<string, any> = {},\n context: Record<string, any> = {},\n origin: string = \"api_errors\"\n ) {\n super(message, {\n name: \"BAD_REQUEST\",\n code: errorCodes.api.BAD_REQUEST,\n isFatal: false,\n origin,\n context,\n });\n this.validationErrors = validationErrors;\n }\n}\n\nexport class NotFoundError extends ApiError {\n constructor(\n message: string,\n entity: string = \"Path\",\n identifier?: string | number,\n context: Record<string, any> = {},\n origin: string = \"api_errors\"\n ) {\n message
|
1
|
+
{"version":3,"sources":["../../src/errors/api_errors.ts"],"sourcesContent":["import { BaseError } from \"./base_error\";\nimport { errorCodes } from \"../constants\";\n\nexport class ApiError extends BaseError {\n constructor(\n message: string,\n {\n name = \"INTERNAL_SERVER_ERROR\",\n code = errorCodes.api.INTERNAL_SERVER_ERROR,\n isFatal = false,\n origin = \"api_errors\",\n context = {},\n }: {\n name?: string;\n code?: number;\n isFatal?: boolean;\n origin?: string;\n context?: Record<string, any>;\n } = {}\n ) {\n super(name, code, message, isFatal, origin, context);\n Error.captureStackTrace(this, this.constructor);\n }\n}\n\nexport class UnauthorizedError extends ApiError {\n constructor(\n message: string = \"Invalid auth credentials\",\n context: Record<string, any> = {},\n origin: string = \"api_errors\"\n ) {\n super(message, {\n name: \"UNAUTHORIZED\",\n code: errorCodes.api.UNAUTHORIZED,\n isFatal: false,\n origin,\n context,\n });\n }\n}\n\nexport class ForbiddenError extends ApiError {\n constructor(\n message: string = \"You do not have permission to perform this action\",\n context: Record<string, any> = {},\n origin: string = \"api_errors\"\n ) {\n super(message, {\n name: \"FORBIDDEN\",\n code: errorCodes.api.FORBIDDEN,\n isFatal: false,\n origin,\n context,\n });\n }\n}\n\nexport class BadRequestError extends ApiError {\n public readonly validationErrors: Record<string, string[]>;\n\n constructor(\n message: string = \"Malformed or invalid request\",\n validationErrors: Record<string, any> = {},\n context: Record<string, any> = {},\n origin: string = \"api_errors\"\n ) {\n super(message, {\n name: \"BAD_REQUEST\",\n code: errorCodes.api.BAD_REQUEST,\n isFatal: false,\n origin,\n context,\n });\n this.validationErrors = validationErrors;\n }\n}\n\nexport class NotFoundError extends ApiError {\n constructor(\n message: string,\n entity: string = \"Path\",\n identifier?: string | number,\n context: Record<string, any> = {},\n origin: string = \"api_errors\"\n ) {\n if (!message) {\n message = identifier\n ? `${entity} with identifier ${identifier} not found`\n : `${entity} not found`;\n }\n\n super(message, {\n name: \"NOT_FOUND\",\n code: errorCodes.api.NOT_FOUND,\n isFatal: false,\n origin,\n context: { entity, identifier, ...context },\n });\n }\n}\n\nexport class RateLimitError extends ApiError {\n constructor(\n message: string = \"Rate limit exceeded\",\n context: Record<string, any> = {},\n origin: string = \"api_errors\"\n ) {\n super(message, {\n name: \"RATE_LIMIT\",\n code: errorCodes.api.TOO_MANY_REQUESTS,\n isFatal: false,\n origin,\n context,\n });\n }\n}\n\nexport class TimeoutError extends ApiError {\n constructor(\n operation: string,\n timeoutMs: number,\n context: Record<string, any> = {},\n origin: string = \"api_errors\"\n ) {\n super(`Operation '${operation}' timed out after ${timeoutMs}ms`, {\n name: \"TIMEOUT\",\n code: errorCodes.api.TIMEOUT_ERROR, // Gateway Timeout\n isFatal: false,\n origin,\n context: { operation, timeoutMs, ...context },\n });\n }\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAEpB,MAAM,iBAAiB,UAAU;AAAA,EACpC,YACI,SACA;AAAA,IACI,OAAO;AAAA,IACP,OAAO,WAAW,IAAI;AAAA,IACtB,UAAU;AAAA,IACV,SAAS;AAAA,IACT,UAAU,CAAC;AAAA,EACf,IAMI,CAAC,GACP;AACE,UAAM,MAAM,MAAM,SAAS,SAAS,QAAQ,OAAO;AACnD,UAAM,kBAAkB,MAAM,KAAK,WAAW;AAAA,EAClD;AACJ;AAEO,MAAM,0BAA0B,SAAS;AAAA,EAC5C,YACI,UAAkB,4BAClB,UAA+B,CAAC,GAChC,SAAiB,cACnB;AACE,UAAM,SAAS;AAAA,MAC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