diff --git a/apps/files/src/utils/davUtils.ts b/apps/files/src/utils/davUtils.ts
index 38137a04d16..cf49df5b278 100644
--- a/apps/files/src/utils/davUtils.ts
+++ b/apps/files/src/utils/davUtils.ts
@@ -4,6 +4,8 @@
*/
import { getCurrentUser } from '@nextcloud/auth'
+import { t } from '@nextcloud/l10n'
+import type { WebDAVClientError } from 'webdav'
/**
* Check whether this is a public share
@@ -21,3 +23,37 @@ export function getToken() {
const tokenElement = document.getElementById('sharingToken') as (HTMLInputElement | null)
return tokenElement?.value
}
+
+/**
+ * Whether error is a WebDAVClientError
+ * @param error - Any exception
+ * @return {boolean} - Whether error is a WebDAVClientError
+ */
+function isWebDAVClientError(error: unknown): error is WebDAVClientError {
+ return error instanceof Error && 'status' in error && 'response' in error
+}
+
+/**
+ * Get a localized error message from webdav request
+ * @param error - An exception from webdav request
+ * @return {string} Localized error message for end user
+ */
+export function humanizeWebDAVError(error: unknown) {
+ if (error instanceof Error) {
+ if (isWebDAVClientError(error)) {
+ const status = error.status || error.response?.status || 0
+ if ([400, 404, 405].includes(status)) {
+ return t('files', 'Folder not found')
+ } else if (status === 403) {
+ return t('files', 'This operation is forbidden')
+ } else if (status === 500) {
+ return t('files', 'This directory is unavailable, please check the logs or contact the administrator')
+ } else if (status === 503) {
+ return t('files', 'Storage is temporarily not available')
+ }
+ }
+ return t('files', 'Unexpected error: {error}', { error: error.message })
+ }
+
+ return t('files', 'Unknown error')
+}
diff --git a/apps/files/src/views/FilesList.vue b/apps/files/src/views/FilesList.vue
index ba206aacad1..314e95f7c49 100644
--- a/apps/files/src/views/FilesList.vue
+++ b/apps/files/src/views/FilesList.vue
@@ -89,22 +89,38 @@
:name="t('files', 'Loading current folder')" />
-
-
-
- {{ t('files', 'Go back') }}
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ {{ t('files', 'Retry') }}
+
+
+
+
+
+
+
+
+
+
+ {{ t('files', 'Go back') }}
+
+
+
+
+
+
+
| CancelablePromise | null,
-
unsubscribeStoreCallback: () => {},
}
},
@@ -475,6 +497,7 @@ export default defineComponent({
methods: {
async fetchContent() {
this.loading = true
+ this.error = null
const dir = this.dir
const currentView = this.currentView
@@ -523,6 +546,7 @@ export default defineComponent({
})
} catch (error) {
logger.error('Error while fetching content', { error })
+ this.error = humanizeWebDAVError(error)
} finally {
this.loading = false
}