From d4d150bb39765a09fa2581e703898f98fb87fce4 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Fri, 13 Mar 2020 15:54:44 -0400 Subject: [PATCH] check for response.error to fix not handling error responses --- lbrytv/setup/publish.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lbrytv/setup/publish.js b/lbrytv/setup/publish.js index a681e1893..59e7b10b7 100644 --- a/lbrytv/setup/publish.js +++ b/lbrytv/setup/publish.js @@ -12,7 +12,7 @@ import { doUpdateUploadProgress } from 'lbryinc'; // to perform calling methods at arbitrary urls // and pass form file fields export default function apiPublishCallViaWeb( - apiCall: (any) => void, + apiCall: any => void, connectionString: string, token: string, method: string, @@ -72,11 +72,11 @@ export default function apiPublishCallViaWeb( return makeRequest(connectionString, 'POST', token, body, params) .then(xhr => { let error; - if (xhr) { - if (xhr.response && xhr.status >= 200 && xhr.status < 300) { + if (xhr && xhr.response) { + if (xhr.status >= 200 && xhr.status < 300 && !xhr.response.error) { return resolve(xhr.response.result); - } else if (xhr.statusText) { - error = new Error(xhr.statusText); + } else if (xhr.response.error) { + error = new Error(xhr.response.error.message); } else { error = new Error(__('Upload likely timed out. Try a smaller file while we work on this.')); }