Skip to content

Commit d700c13

Browse files
Pytalicewind1991
authored andcommitted
feat(files): Display meaningful error message on move failure
Signed-off-by: Christopher Ng <chrng8@gmail.com>
1 parent c307730 commit d700c13

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

apps/files/src/actions/moveOrCopyAction.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import '@nextcloud/dialogs/style.css'
2323
import type { Folder, Node, View } from '@nextcloud/files'
2424
import type { IFilePickerButton } from '@nextcloud/dialogs'
25-
import type { FileStat, ResponseDataDetailed } from 'webdav'
25+
import type { FileStat, ResponseDataDetailed, WebDAVClientError } from 'webdav'
2626
import type { MoveCopyResult } from './moveOrCopyActionUtils'
2727

2828
import { FilePickerClosed, getFilePickerBuilder, showError, showInfo, TOAST_PERMANENT_TIMEOUT } from '@nextcloud/dialogs'
@@ -184,7 +184,18 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth
184184
}
185185
// getting here means either no conflict, file was renamed to keep both files
186186
// in a conflict, or the selected file was chosen to be kept during the conflict
187-
await client.moveFile(currentPath, join(destinationPath, node.basename))
187+
try {
188+
await client.moveFile(currentPath, join(destinationPath, node.basename))
189+
} catch (error) {
190+
const parser = new DOMParser()
191+
const text = await (error as WebDAVClientError).response?.text()
192+
const message = parser.parseFromString(text ?? '', 'text/xml')
193+
.querySelector('message')?.textContent
194+
if (message) {
195+
showError(message)
196+
}
197+
throw error
198+
}
188199
// Delete the node as it will be fetched again
189200
// when navigating to the destination folder
190201
emit('files:node:deleted', node)

0 commit comments

Comments
 (0)