Skip to content

Commit

Permalink
Show the actual error on share requests
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl authored and backportbot[bot] committed Jan 27, 2021
1 parent b527ffc commit cf23bff
Showing 1 changed file with 15 additions and 3 deletions.
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 cf23bff

Please sign in to comment.