mirror of
https://github.com/immich-app/immich.git
synced 2025-01-13 15:35:15 +02:00
fix: update error handling to match new API (#7117)
This commit is contained in:
parent
6adff50f0a
commit
2906950188
@ -3,11 +3,11 @@
|
|||||||
notificationController,
|
notificationController,
|
||||||
NotificationType,
|
NotificationType,
|
||||||
} from '$lib/components/shared-components/notification/notification';
|
} from '$lib/components/shared-components/notification/notification';
|
||||||
import { type ApiError } from '$lib/utils';
|
|
||||||
import { changePassword } from '@immich/sdk';
|
import { changePassword } from '@immich/sdk';
|
||||||
import { fade } from 'svelte/transition';
|
import { fade } from 'svelte/transition';
|
||||||
import SettingInputField, { SettingInputFieldType } from '../admin-page/settings/setting-input-field.svelte';
|
import SettingInputField, { SettingInputFieldType } from '../admin-page/settings/setting-input-field.svelte';
|
||||||
import Button from '../elements/buttons/button.svelte';
|
import Button from '../elements/buttons/button.svelte';
|
||||||
|
import type { HttpError } from '@sveltejs/kit';
|
||||||
|
|
||||||
let password = '';
|
let password = '';
|
||||||
let newPassword = '';
|
let newPassword = '';
|
||||||
@ -28,7 +28,7 @@
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error [user-profile] [changePassword]', error);
|
console.error('Error [user-profile] [changePassword]', error);
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
message: (error as ApiError)?.response?.data?.message || 'Unable to change password',
|
message: (error as HttpError)?.body?.message || 'Unable to change password',
|
||||||
type: NotificationType.Error,
|
type: NotificationType.Error,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import {
|
|||||||
type UserResponseDto,
|
type UserResponseDto,
|
||||||
} from '@immich/sdk';
|
} from '@immich/sdk';
|
||||||
import { common } from '@immich/sdk/axios';
|
import { common } from '@immich/sdk/axios';
|
||||||
import type { AxiosError } from 'axios';
|
|
||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
|
|
||||||
interface UpdateParamAction {
|
interface UpdateParamAction {
|
||||||
@ -135,8 +134,6 @@ export const getAssetJobMessage = (job: AssetJobName) => {
|
|||||||
return messages[job];
|
return messages[job];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ApiError = AxiosError<{ message: string }>;
|
|
||||||
|
|
||||||
export const copyToClipboard = async (secret: string) => {
|
export const copyToClipboard = async (secret: string) => {
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(secret);
|
await navigator.clipboard.writeText(secret);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import type { ApiError } from '$lib/utils';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { notificationController, NotificationType } from '../components/shared-components/notification/notification';
|
import { notificationController, NotificationType } from '../components/shared-components/notification/notification';
|
||||||
|
import type { HttpError } from '@sveltejs/kit';
|
||||||
|
|
||||||
export async function getServerErrorMessage(error: unknown) {
|
export async function getServerErrorMessage(error: unknown) {
|
||||||
let data = (error as ApiError)?.response?.data;
|
let data = (error as HttpError)?.body;
|
||||||
if (data instanceof Blob) {
|
if (data instanceof Blob) {
|
||||||
const response = await data.text();
|
const response = await data.text();
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user