(error: unknown)
| 28 | }; |
| 29 | |
| 30 | export 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 | |
| 58 | export function handleWebDavError(error: unknown, statusOverride?: number): Response { |
| 59 | console.error(error); |
no outgoing calls
no test coverage detected