mirror of
https://github.com/immich-app/immich.git
synced 2025-01-01 08:31: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 { tick } from 'svelte';
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
import { getServerErrorMessage, handleError } from './handle-error';
|
import { handleError } from './handle-error';
|
||||||
|
|
||||||
export const addDummyItems = () => {
|
export const addDummyItems = () => {
|
||||||
uploadAssetsStore.addItem({ id: 'asset-0', file: { name: 'asset0.jpg', size: 123_456 } as File });
|
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;
|
return responseData.id;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error, $t('errors.unable_to_upload_file'));
|
const errorMessage = handleError(error, $t('errors.unable_to_upload_file'));
|
||||||
const reason = getServerErrorMessage(error) || error;
|
|
||||||
uploadAssetsStore.track('error');
|
uploadAssetsStore.track('error');
|
||||||
uploadAssetsStore.updateItem(deviceAssetId, { state: UploadState.ERROR, error: reason });
|
uploadAssetsStore.updateItem(deviceAssetId, { state: UploadState.ERROR, error: errorMessage });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,13 @@ export function handleError(error: unknown, message: string) {
|
||||||
serverMessage = `${String(serverMessage).slice(0, 75)}\n(Immich Server Error)`;
|
serverMessage = `${String(serverMessage).slice(0, 75)}\n(Immich Server Error)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
notificationController.show({
|
const errorMessage = serverMessage || message;
|
||||||
message: serverMessage || message,
|
|
||||||
type: NotificationType.Error,
|
notificationController.show({ message: errorMessage, type: NotificationType.Error });
|
||||||
});
|
|
||||||
|
return errorMessage;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue