handy online tools for AT Protocol boat.kelinci.net
atproto bluesky atcute typescript solidjs
at trunk 29 lines 748 B view raw
1import { ClientResponseError } from '@atcute/client'; 2 3export const formatQueryError = (err: unknown) => { 4 if (err instanceof ClientResponseError) { 5 const error = err.error; 6 7 if (error === 'InvalidToken' || error === 'ExpiredToken') { 8 return `Account session is no longer valid`; 9 } 10 11 if (error === 'UpstreamFailure') { 12 return `Server appears to be experiencing issues, try again later`; 13 } 14 15 if (error === 'InternalServerError') { 16 return `Server is having issues processing this request, try again later`; 17 } 18 19 return err.message; 20 } 21 22 if (err instanceof Error) { 23 if (/NetworkError|Failed to fetch|timed out|abort/.test(err.message)) { 24 return `Unable to access the internet, try again later`; 25 } 26 } 27 28 return '' + err; 29};