mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat(web)!: SPA (#5069)
* feat(web): SPA * chore: remove unnecessary prune * feat(web): merge with immich-server * Correct method name * fix: bugs, docs, workflows, etc. * chore: keep dockerignore for dev * chore: remove license * fix: expose 2283 --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
5118d261ab
commit
adae5dd758
115 changed files with 730 additions and 1446 deletions
40
web/src/hooks.client.ts
Normal file
40
web/src/hooks.client.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import type { HandleClientError } from '@sveltejs/kit';
|
||||
import type { AxiosError, AxiosResponse } from 'axios';
|
||||
|
||||
const LOG_PREFIX = '[hooks.client.ts]';
|
||||
const DEFAULT_MESSAGE = 'Hmm, not sure about that. Check the logs or open a ticket?';
|
||||
|
||||
const parseError = (error: unknown) => {
|
||||
const httpError = error as AxiosError;
|
||||
const request = httpError?.request as Request & { path: string };
|
||||
const response = httpError?.response as AxiosResponse<{
|
||||
message: string;
|
||||
statusCode: number;
|
||||
error: string;
|
||||
}>;
|
||||
|
||||
let code = response?.data?.statusCode || response?.status || httpError.code || '500';
|
||||
if (response) {
|
||||
code += ` - ${response.data?.error || response.statusText}`;
|
||||
}
|
||||
|
||||
if (request && response) {
|
||||
console.log({
|
||||
status: response.status,
|
||||
url: `${request.method} ${request.path}`,
|
||||
response: response.data || 'No data',
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
message: response?.data?.message || httpError?.message || DEFAULT_MESSAGE,
|
||||
code,
|
||||
stack: httpError?.stack,
|
||||
};
|
||||
};
|
||||
|
||||
export const handleError: HandleClientError = ({ error }) => {
|
||||
const result = parseError(error);
|
||||
console.error(`${LOG_PREFIX}:handleError ${result.message}`);
|
||||
return result;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue