Skip to content

Commit 15849c2

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 42defb7 commit 15849c2

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
@@ -7,7 +7,6 @@ import type { IFilePickerButton } from '@nextcloud/dialogs'
77
import type { FileStat, ResponseDataDetailed, WebDAVClientError } from 'webdav'
88
import type { MoveCopyResult } from './moveOrCopyActionUtils'
99

10-
import { isAxiosError } from '@nextcloud/axios'
1110
import { FilePickerClosed, getFilePickerBuilder, openConflictPicker, showError, showLoading } from '@nextcloud/dialogs'
1211
import { emit } from '@nextcloud/event-bus'
1312
import { FileAction, FileType, getUniqueName, NodeStatus, Permission } from '@nextcloud/files'
@@ -196,21 +195,19 @@ export async function * handleCopyMoveNodesTo(nodes: INode[], destination: IFold
196195
}
197196
} catch (error) {
198197
logger.debug(`Error while trying to ${method === MoveCopyAction.COPY ? 'copy' : 'move'} node`, { node, error })
199-
if (isAxiosError(error)) {
200-
if (error.response?.status === 412) {
201-
throw new HintException(t('files', 'A file or folder with that name already exists in this folder'))
202-
} else if (error.response?.status === 423) {
203-
throw new HintException(t('files', 'The files are locked'))
204-
} else if (error.response?.status === 404) {
205-
throw new HintException(t('files', 'The file does not exist anymore'))
206-
} else if ('response' in error && error.response) {
207-
const parser = new DOMParser()
208-
const text = await (error as WebDAVClientError).response!.text()
209-
const message = parser.parseFromString(text ?? '', 'text/xml')
210-
.querySelector('message')?.textContent
211-
if (message) {
212-
throw new HintException(message)
213-
}
198+
if (error.response?.status === 412) {
199+
throw new HintException(t('files', 'A file or folder with that name already exists in this folder'))
200+
} else if (error.response?.status === 423) {
201+
throw new HintException(t('files', 'The files are locked'))
202+
} else if (error.response?.status === 404) {
203+
throw new HintException(t('files', 'The file does not exist anymore'))
204+
} else if ('response' in error && error.response) {
205+
const parser = new DOMParser()
206+
const text = await (error as WebDAVClientError).response!.text()
207+
const message = parser.parseFromString(text ?? '', 'text/xml')
208+
.querySelector('message')?.textContent
209+
if (message) {
210+
throw new HintException(message)
214211
}
215212
}
216213
throw error

0 commit comments

Comments
 (0)