mirror of
https://github.com/get-drexa/drive.git
synced 2025-12-01 14:01:40 +00:00
refactor: migrate to vite and restructure repo
Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
35
packages/convex/shared/error.ts
Normal file
35
packages/convex/shared/error.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { ConvexError } from "convex/values"
|
||||
|
||||
export enum Code {
|
||||
Conflict = "Conflict",
|
||||
DirectoryExists = "DirectoryExists",
|
||||
DirectoryNotFound = "DirectoryNotFound",
|
||||
FileExists = "FileExists",
|
||||
FileNotFound = "FileNotFound",
|
||||
Internal = "Internal",
|
||||
Unauthenticated = "Unauthenticated",
|
||||
NotFound = "NotFound",
|
||||
}
|
||||
|
||||
export type ApplicationErrorData = { code: Code; message?: string }
|
||||
export type ApplicationError = ConvexError<ApplicationErrorData>
|
||||
|
||||
export function isApplicationError(error: unknown): error is ApplicationError {
|
||||
return error instanceof ConvexError && "code" in error.data
|
||||
}
|
||||
|
||||
export function create(code: Code, message?: string): ApplicationError {
|
||||
return new ConvexError({
|
||||
code,
|
||||
message:
|
||||
code === Code.Internal ? "Internal application error" : message,
|
||||
})
|
||||
}
|
||||
|
||||
export function createJson(code: Code, message?: string): ApplicationErrorData {
|
||||
return {
|
||||
code,
|
||||
message:
|
||||
code === Code.Internal ? "Internal application error" : message,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user