Skip to content

Commit

Permalink
Merge pull request #25352 from nextcloud/backport/25185/stable20
Browse files Browse the repository at this point in the history
[stable20] Show the actual error on share requests
  • Loading branch information
juliushaertl committed Jan 28, 2021
2 parents d7f6a48 + a2476e1 commit 2c23dd4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/files_sharing/js/dist/files_sharing_tab.js.map

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions apps/files_sharing/src/mixins/ShareRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ export default {
return new Share(request.data.ocs.data)
} catch (error) {
console.error('Error while creating share', error)
OC.Notification.showTemporary(t('files_sharing', 'Error creating the share'), { type: 'error' })
const errorMessage = error?.response?.data?.ocs?.meta?.message
OC.Notification.showTemporary(
errorMessage ? t('files_sharing', 'Error creating the share: {errorMessage}', { errorMessage }) : t('files_sharing', 'Error creating the share'),
{ type: 'error' }
)
throw error
}
},
Expand All @@ -79,7 +83,11 @@ export default {
return true
} catch (error) {
console.error('Error while deleting share', error)
OC.Notification.showTemporary(t('files_sharing', 'Error deleting the share'), { type: 'error' })
const errorMessage = error?.response?.data?.ocs?.meta?.message
OC.Notification.showTemporary(
errorMessage ? t('files_sharing', 'Error deleting the share: {errorMessage}', { errorMessage }) : t('files_sharing', 'Error deleting the share'),
{ type: 'error' }
)
throw error
}
},
Expand All @@ -100,7 +108,11 @@ export default {
} catch (error) {
console.error('Error while updating share', error)
if (error.response.status !== 400) {
OC.Notification.showTemporary(t('files_sharing', 'Error updating the share'), { type: 'error' })
const errorMessage = error?.response?.data?.ocs?.meta?.message
OC.Notification.showTemporary(
errorMessage ? t('files_sharing', 'Error updating the share: {errorMessage}', { errorMessage }) : t('files_sharing', 'Error updating the share'),
{ type: 'error' }
)
}
const message = error.response.data.ocs.meta.message
throw new Error(message)
Expand Down

0 comments on commit 2c23dd4

Please sign in to comment.