This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: return 404 if Storipress API return 404 (#321)
- Loading branch information
Showing
8 changed files
with
93 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { PayloadScope } from '../types' | ||
|
||
export class KarbonError extends Error { | ||
name = 'KarbonError' | ||
httpStatus = 500 | ||
|
||
setHttpStatus(code: number) { | ||
this.httpStatus = code | ||
} | ||
} | ||
|
||
export function isKarbonError(error: unknown): error is KarbonError { | ||
return error instanceof KarbonError | ||
} | ||
|
||
export interface KarbonErrorMeta { | ||
__isKarbonError: true | ||
payloadScope?: PayloadScope | ||
function?: string | ||
httpStatus?: number | ||
message: string | ||
stack?: string | ||
error?: unknown | ||
} | ||
|
||
export function isKarbonErrorMeta(error: unknown): error is KarbonErrorMeta { | ||
const _error = error as KarbonErrorMeta | ||
return Boolean(_error.__isKarbonError) | ||
} |