MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / mapFileSystemErrorToStatus

Function mapFileSystemErrorToStatus

lib/utils/webdav.ts:30–56  ·  view source on GitHub ↗
(error: unknown)

Source from the content-addressed store, hash-verified

28};
29
30export function mapFileSystemErrorToStatus(error: unknown): number {
31 if (error instanceof Deno.errors.PermissionDenied) {
32 return 403;
33 }
34
35 if (error instanceof Deno.errors.AlreadyExists) {
36 return 409;
37 }
38
39 if (error instanceof Deno.errors.NotADirectory) {
40 return 409;
41 }
42
43 if (error instanceof Deno.errors.FilesystemLoop) {
44 return 508;
45 }
46
47 if (error instanceof Deno.errors.NotFound) {
48 return 404;
49 }
50
51 if (error instanceof Error && (error as { code?: string }).code === 'ENOSPC') {
52 return 507;
53 }
54
55 return 500;
56}
57
58export function handleWebDavError(error: unknown, statusOverride?: number): Response {
59 console.error(error);

Callers 2

webdav_test.tsFile · 0.90
handleWebDavErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected