Skip to content

Commit

Permalink
Fix return type when searching errors
Browse files Browse the repository at this point in the history
  • Loading branch information
krasun committed Apr 30, 2024
1 parent 7276e6c commit 509d75c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "screenshotone-errors",
"homepage": "https://screenshotone.com",
"version": "1.0.1",
"version": "1.0.2",
"description": "Errors produced by the ScreenshotOne API.",
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface APIError {
ErrorDocumentationLink: string;
}

const Errors: Record<ErrorCode, APIError> = {
const allErrors: Record<ErrorCode, APIError> = {
[ErrorCode.Timeout]: {
HTTPStatusCode: 500,
ErrorCode: "timeout_error",
Expand All @@ -20,13 +20,13 @@ const Errors: Record<ErrorCode, APIError> = {
};

export function APIErrorByCode(code: string) {
if ((code as ErrorCode) in Errors) {
return code as ErrorCode;
if ((code as ErrorCode) in allErrors) {
return allErrors[code as ErrorCode];
}

return null;
}

export function APIError(code: ErrorCode) {
return Errors[code];
return allErrors[code];
}

0 comments on commit 509d75c

Please sign in to comment.