Skip to content

Commit 0d39bfd

Browse files
committed
fix(files): fix custom client-side error messages on move/copy actions
move/copy actions don't use axios these days. Signed-off-by: Jonas <jonas@freesources.org>
1 parent 5c0fe4c commit 0d39bfd

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

apps/files/src/actions/moveOrCopyAction.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import type { MoveCopyResult } from './moveOrCopyActionUtils.ts'
1010

1111
import FolderMoveSvg from '@mdi/svg/svg/folder-move-outline.svg?raw'
1212
import CopyIconSvg from '@mdi/svg/svg/folder-multiple-outline.svg?raw'
13-
import { isAxiosError } from '@nextcloud/axios'
1413
import { FilePickerClosed, getFilePickerBuilder, openConflictPicker, showError, showLoading } from '@nextcloud/dialogs'
1514
import { emit } from '@nextcloud/event-bus'
1615
import { FileType, getUniqueName, NodeStatus, Permission } from '@nextcloud/files'
@@ -191,21 +190,19 @@ export async function* handleCopyMoveNodesTo(nodes: INode[], destination: IFolde
191190
}
192191
} catch (error) {
193192
logger.debug(`Error while trying to ${method === MoveCopyAction.COPY ? 'copy' : 'move'} node`, { node, error })
194-
if (isAxiosError(error)) {
195-
if (error.response?.status === 412) {
196-
throw new HintException(t('files', 'A file or folder with that name already exists in this folder'))
197-
} else if (error.response?.status === 423) {
198-
throw new HintException(t('files', 'The files are locked'))
199-
} else if (error.response?.status === 404) {
200-
throw new HintException(t('files', 'The file does not exist anymore'))
201-
} else if ('response' in error && error.response) {
202-
const parser = new DOMParser()
203-
const text = await (error as WebDAVClientError).response!.text()
204-
const message = parser.parseFromString(text ?? '', 'text/xml')
205-
.querySelector('message')?.textContent
206-
if (message) {
207-
throw new HintException(message)
208-
}
193+
if (error.response?.status === 412) {
194+
throw new HintException(t('files', 'A file or folder with that name already exists in this folder'))
195+
} else if (error.response?.status === 423) {
196+
throw new HintException(t('files', 'The files are locked'))
197+
} else if (error.response?.status === 404) {
198+
throw new HintException(t('files', 'The file does not exist anymore'))
199+
} else if ('response' in error && error.response) {
200+
const parser = new DOMParser()
201+
const text = await (error as WebDAVClientError).response!.text()
202+
const message = parser.parseFromString(text ?? '', 'text/xml')
203+
.querySelector('message')?.textContent
204+
if (message) {
205+
throw new HintException(message)
209206
}
210207
}
211208
throw error

0 commit comments

Comments
 (0)