Skip to content

Commit eb902a4

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

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
@@ -4,7 +4,7 @@
44
*/
55
import type { Folder, Node, View } from '@nextcloud/files'
66
import type { IFilePickerButton } from '@nextcloud/dialogs'
7-
import type { FileStat, ResponseDataDetailed } from 'webdav'
7+
import type { FileStat, ResponseDataDetailed, WebDAVClientError } from 'webdav'
88
import type { MoveCopyResult } from './moveOrCopyActionUtils'
99

1010
import { isAxiosError } from '@nextcloud/axios'
@@ -165,7 +165,18 @@ export const handleCopyMoveNodeTo = async (node: Node, destination: Folder, meth
165165
}
166166
// getting here means either no conflict, file was renamed to keep both files
167167
// in a conflict, or the selected file was chosen to be kept during the conflict
168-
await client.moveFile(currentPath, join(destinationPath, node.basename))
168+
try {
169+
await client.moveFile(currentPath, join(destinationPath, node.basename))
170+
} catch (error) {
171+
const parser = new DOMParser()
172+
const text = await (error as WebDAVClientError).response?.text()
173+
const message = parser.parseFromString(text ?? '', 'text/xml')
174+
.querySelector('message')?.textContent
175+
if (message) {
176+
showError(message)
177+
}
178+
throw error
179+
}
169180
// Delete the node as it will be fetched again
170181
// when navigating to the destination folder
171182
emit('files:node:deleted', node)

0 commit comments

Comments
 (0)