mirror of
https://github.com/get-drexa/drive.git
synced 2025-12-01 05:51:39 +00:00
feat: check for name conflict on file/dir move
Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
import { ConvexError } from "convex/values"
|
||||
|
||||
export enum Code {
|
||||
export enum Code {
|
||||
Conflict = "Conflict",
|
||||
DirectoryExists = "DirectoryExists",
|
||||
DirectoryNotFound = "DirectoryNotFound",
|
||||
FileExists = "FileExists",
|
||||
FileNotFound = "FileNotFound",
|
||||
Internal = "Internal",
|
||||
Unauthenticated = "Unauthenticated",
|
||||
}
|
||||
|
||||
export type ApplicationError = ConvexError<{ code: Code; message?: string }>
|
||||
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
|
||||
@@ -22,3 +24,11 @@ export function create(code: Code, message?: string): ApplicationError {
|
||||
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