1
0
Fork 0
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:
Jason Rasmussen 2024-09-09 23:50:09 -04:00 committed by GitHub
parent 710cbd694b
commit 2c639d7fe4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 8 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}