From 36a19c4ba8827d3de21ac365ac30af1bfc1d4a45 Mon Sep 17 00:00:00 2001 From: 1Computer1 Date: Thu, 5 Sep 2019 22:04:44 -0400 Subject: [PATCH] Fix error handling from Myriad --- src/struct/Myriad.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/struct/Myriad.js b/src/struct/Myriad.js index e7d5acb..ba4d0dc 100644 --- a/src/struct/Myriad.js +++ b/src/struct/Myriad.js @@ -21,15 +21,17 @@ class Myriad { }); if (!response.ok) { - if (response.status === 404 && response.statusText === 'Not Found') { - return [false, 'Invalid language']; + const status = response.status; + const text = await response.text(); + if (status === 404 && text === `Language ${language} was not found`) { + return [false, `Invalid language ${language}`]; } - if (response.status === 500 && response.statusText === 'Evaluation failed') { + if (status === 500 && text === 'Evaluation failed') { return [false, 'Evaluation failed']; } - if (response.status === 504 && response.statusText === 'Evaluation timed out') { + if (status === 504 && text === 'Evaluation timed out') { return [false, 'Evaluation timed out']; }