fix(upload): errorFromDirectUploadMessage should take Error or string
This commit is contained in:
parent
f70344b89b
commit
bca97268a8
2 changed files with 4 additions and 2 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue