diff options
author | Joas Schilling <coding@schilljs.com> | 2022-08-02 11:24:49 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-08-31 08:15:39 +0200 |
commit | e1f9b5a99bc628b355eac9e8fd9df12fa8982840 (patch) | |
tree | 00f1fe157f486a56fd221a39f05710e4e4cac3a1 /src | |
parent | 53de079e50e06b0ba7ae76770d4fc1a1918c1eba (diff) |
Improve error handling
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/NewMessageForm/NewMessageForm.vue | 1 | ||||
-rw-r--r-- | src/services/filesSharingServices.js | 13 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/components/NewMessageForm/NewMessageForm.vue b/src/components/NewMessageForm/NewMessageForm.vue index ffd18b7c0..8072de93d 100644 --- a/src/components/NewMessageForm/NewMessageForm.vue +++ b/src/components/NewMessageForm/NewMessageForm.vue @@ -644,6 +644,7 @@ export default { async handleCreateTextFile() { const filePath = this.textFileTitle + '.md' await createTextFile(filePath) + // FIXME If creation failed we should not share, as it could be an old/other file with the same name. const response = await shareFile(filePath, this.token) // TODO: before getting the link from the system message we need // to wait till the message itself is received diff --git a/src/services/filesSharingServices.js b/src/services/filesSharingServices.js index 26008a1a7..04e6cf492 100644 --- a/src/services/filesSharingServices.js +++ b/src/services/filesSharingServices.js @@ -34,7 +34,7 @@ import { showError } from '@nextcloud/dialogs' */ const shareFile = async function(path, token, referenceId, metadata) { try { - return axios.post( + return await axios.post( generateOcsUrl('apps/files_sharing/api/v1/shares'), { shareType: 10, // OC.Share.SHARE_TYPE_ROOM, @@ -63,13 +63,20 @@ const shareFile = async function(path, token, referenceId, metadata) { */ const createTextFile = async function(filePath) { try { - return axios.post( + return await axios.post( generateOcsUrl('apps/files/api/v1/templates/create'), { filePath, }) } catch (error) { - console.debug(error) + // FIXME: errors should be handled by called instead + if (error?.response?.data?.ocs?.meta?.message) { + console.error('Error while creating file: ' + error.response.data.ocs.meta.message) + showError(error.response.data.ocs.meta.message) + } else { + console.error('Error while creating file: Unknown error') + showError(t('spreed', 'Error while creating file')) + } } } |