Moved later/gitgram-ai/gitgram/ to apps/ritgram/ (fresh history; full history stays in caelum0x/gitgram). AITimeMachine stays separate in later/gitgram-ai per the Rithub master plan. Logs, pid files and env files are ignored; GPL-3.0 mobile/proximity noted in THIRD_PARTY_NOTICES. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
23 lines
659 B
TypeScript
23 lines
659 B
TypeScript
/**
|
|
* Extract a user-friendly error message from an unknown error.
|
|
* Works with Axios errors, standard Errors, and unknown values.
|
|
*/
|
|
export function getErrorMessage(error: unknown): string {
|
|
if (error instanceof Error) {
|
|
const axiosError = error as Error & {
|
|
response?: { data?: { message?: string; error?: string } }
|
|
}
|
|
if (axiosError.response?.data?.message) {
|
|
return axiosError.response.data.message
|
|
}
|
|
if (axiosError.response?.data?.error) {
|
|
return axiosError.response.data.error
|
|
}
|
|
return error.message
|
|
}
|
|
if (typeof error === 'string') {
|
|
return error
|
|
}
|
|
return 'An unexpected error occurred'
|
|
}
|