Skip to content

Commit eae5c19

Browse files
authored
Don't log Non-JSON response errors to the Output channel (#892)
1 parent 1a1a11b commit eae5c19

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/api/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ export class AtelierAPI {
327327
// User likely ran out of licenses
328328
throw {
329329
statusCode: response.status,
330-
message: `The server at ${host}:${port} is unavailable. Check License Usage.`,
330+
message: response.statusText,
331+
errorText: `The server at ${host}:${port} is unavailable. Check License Usage.`,
331332
};
332333
}
333334
if (response.status === 401) {
@@ -355,16 +356,17 @@ export class AtelierAPI {
355356
const buffer = await response.buffer();
356357

357358
const responseString = buffer.toString("utf-8");
358-
if (!responseString.startsWith("{")) {
359-
outputConsole(["", `Non-JSON response to ${path}`, ...responseString.split("\r\n")]);
359+
let data: Atelier.Response;
360+
try {
361+
data = JSON.parse(responseString);
362+
} catch {
360363
throw {
361-
statusCode: 500,
362-
message: `Non-JSON response to ${path} request. View 'ObjectScript' channel on OUTPUT tab of Panel for details.`,
364+
statusCode: response.status,
365+
message: response.statusText,
366+
errorText: `Non-JSON response to ${path} request. Is the web server suppressing detailed errors?`,
363367
};
364368
}
365369

366-
const data: Atelier.Response = JSON.parse(responseString);
367-
368370
// Decode encoded content
369371
if (data.result && data.result.enc && data.result.content) {
370372
data.result.enc = false;

0 commit comments

Comments
 (0)