diff --git a/app/javascript/shared/activestorage/file-upload-error.ts b/app/javascript/shared/activestorage/file-upload-error.ts index 7265ee67e..cd7aeb292 100644 --- a/app/javascript/shared/activestorage/file-upload-error.ts +++ b/app/javascript/shared/activestorage/file-upload-error.ts @@ -63,7 +63,9 @@ export default class FileUploadError extends Error { // 2. Create each kind of error on a different line // (so that Sentry knows they are different kind of errors, from // the line they were created.) -export function errorFromDirectUploadMessage(message: string) { +export function errorFromDirectUploadMessage(messageOrError: string | Error) { + const message = + typeof messageOrError == 'string' ? messageOrError : messageOrError.message; const matches = message.match(/ Status: ([0-9]{1,3})/); const status = matches ? parseInt(matches[1], 10) : undefined; diff --git a/app/javascript/shared/activestorage/uploader.ts b/app/javascript/shared/activestorage/uploader.ts index abbe6ac80..8fd789ab8 100644 --- a/app/javascript/shared/activestorage/uploader.ts +++ b/app/javascript/shared/activestorage/uploader.ts @@ -60,7 +60,7 @@ export default class Uploader { return new Promise((resolve, reject) => { this.directUpload.create((errorMsg, attributes) => { if (errorMsg) { - const error = errorFromDirectUploadMessage(errorMsg.message); + const error = errorFromDirectUploadMessage(errorMsg); reject(error); } else { resolve(attributes.signed_id);