Show the actual error on share requests

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2021-01-18 15:34:17 +01:00
parent bfe4a84ca7
commit f75e7e7b54
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
3 changed files with 17 additions and 5 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -59,7 +59,11 @@ export default {
return new Share(request.data.ocs.data) return new Share(request.data.ocs.data)
} catch (error) { } catch (error) {
console.error('Error while creating share', 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 throw error
} }
}, },
@ -79,7 +83,11 @@ export default {
return true return true
} catch (error) { } catch (error) {
console.error('Error while deleting share', 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 throw error
} }
}, },
@ -100,7 +108,11 @@ export default {
} catch (error) { } catch (error) {
console.error('Error while updating share', error) console.error('Error while updating share', error)
if (error.response.status !== 400) { 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 const message = error.response.data.ocs.meta.message
throw new Error(message) throw new Error(message)