Merge pull request #7192 from tchak/fix-direct-upload-error

fix(upload): errorFromDirectUploadMessage should take Error or string
This commit is contained in:
Paul Chavard 2022-04-25 13:17:59 +02:00 committed by GitHub
commit c608e6b4e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -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;

View file

@ -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);