Skip to content

Commit 83bb29d

Browse files
Merge pull request #62133 from nextcloud/backport/59954/stable32
[stable32] fix(files): fix custom client-side error messages on move/copy actions
2 parents b44dee1 + 319ab88 commit 83bb29d

5 files changed

Lines changed: 19 additions & 22 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

dist/files-init.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)