mirror of
https://github.com/immich-app/immich.git
synced 2024-12-28 22:51:59 +00:00
fix(web): show upload error message on network error (#12533)
This commit is contained in:
parent
710cbd694b
commit
2c639d7fe4
2 changed files with 9 additions and 8 deletions
|
@ -15,7 +15,7 @@ import {
|
|||
import { tick } from 'svelte';
|
||||
import { t } from 'svelte-i18n';
|
||||
import { get } from 'svelte/store';
|
||||
import { getServerErrorMessage, handleError } from './handle-error';
|
||||
import { handleError } from './handle-error';
|
||||
|
||||
export const addDummyItems = () => {
|
||||
uploadAssetsStore.addItem({ id: 'asset-0', file: { name: 'asset0.jpg', size: 123_456 } as File });
|
||||
|
@ -202,10 +202,9 @@ async function fileUploader(assetFile: File, albumId?: string, replaceAssetId?:
|
|||
|
||||
return responseData.id;
|
||||
} catch (error) {
|
||||
handleError(error, $t('errors.unable_to_upload_file'));
|
||||
const reason = getServerErrorMessage(error) || error;
|
||||
const errorMessage = handleError(error, $t('errors.unable_to_upload_file'));
|
||||
uploadAssetsStore.track('error');
|
||||
uploadAssetsStore.updateItem(deviceAssetId, { state: UploadState.ERROR, error: reason });
|
||||
uploadAssetsStore.updateItem(deviceAssetId, { state: UploadState.ERROR, error: errorMessage });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,13 @@ export function handleError(error: unknown, message: string) {
|
|||
serverMessage = `${String(serverMessage).slice(0, 75)}\n(Immich Server Error)`;
|
||||
}
|
||||
|
||||
notificationController.show({
|
||||
message: serverMessage || message,
|
||||
type: NotificationType.Error,
|
||||
});
|
||||
const errorMessage = serverMessage || message;
|
||||
|
||||
notificationController.show({ message: errorMessage, type: NotificationType.Error });
|
||||
|
||||
return errorMessage;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue