JavaScript-optional public web frontend for Bluesky anartia.kelinci.net
sveltekit atcute bluesky typescript svelte
at trunk 36 lines 902 B view raw
1import { ClientResponseError } from '@atcute/client'; 2import type { HandleServerError } from '@sveltejs/kit'; 3 4export const handleError: HandleServerError = async ({ error, event, status, message }) => { 5 console.error(error); 6 7 if (error instanceof ClientResponseError) { 8 if (error.status === 403) { 9 return { 10 message: `Upstream server is forbidding access to this resource`, 11 }; 12 } 13 14 if (error.error === 'AuthRequired' || error.error === 'auth required') { 15 return { 16 message: `Upstream server is requiring authentication to access this resource`, 17 }; 18 } 19 20 if (error.error === 'InternalServerError' || error.description === 'Internal Server Error') { 21 return { 22 message: `Upstream server returned an internal error`, 23 }; 24 } 25 } 26 27 if (status === 404) { 28 return { 29 message: `Page not found`, 30 }; 31 } 32 33 return { 34 message: `Something went wrong, sorry about that`, 35 }; 36};