Merge pull request #7192 from tchak/fix-direct-upload-error
fix(upload): errorFromDirectUploadMessage should take Error or string
This commit is contained in:
commit
c608e6b4e0
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
|
// 2. Create each kind of error on a different line
|
||||||
// (so that Sentry knows they are different kind of errors, from
|
// (so that Sentry knows they are different kind of errors, from
|
||||||
// the line they were created.)
|
// 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 matches = message.match(/ Status: ([0-9]{1,3})/);
|
||||||
const status = matches ? parseInt(matches[1], 10) : undefined;
|
const status = matches ? parseInt(matches[1], 10) : undefined;
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ export default class Uploader {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.directUpload.create((errorMsg, attributes) => {
|
this.directUpload.create((errorMsg, attributes) => {
|
||||||
if (errorMsg) {
|
if (errorMsg) {
|
||||||
const error = errorFromDirectUploadMessage(errorMsg.message);
|
const error = errorFromDirectUploadMessage(errorMsg);
|
||||||
reject(error);
|
reject(error);
|
||||||
} else {
|
} else {
|
||||||
resolve(attributes.signed_id);
|
resolve(attributes.signed_id);
|
||||||
|
|
Loading…
Reference in a new issue