Skip to content

Commit 7ff083a

Browse files
authored
Merge pull request #588 from highcharts/bugfix/improper-status-code
bugfix/improper-status-code
2 parents 4688a0a + 0e3da2b commit 7ff083a

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

lib/browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export async function newPage(poolResource) {
244244

245245
// Throw an error in case of no connected browser
246246
if (!browser || !browser.connected) {
247-
throw new ExportError(`[browser] Browser is not yet connected.`, 400);
247+
throw new ExportError(`[browser] Browser is not yet connected.`, 500);
248248
}
249249

250250
// Create a page

lib/cache.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ export const fetchAndProcessScript = async (
140140

141141
if (shouldThrowError) {
142142
throw new ExportError(
143-
`Could not fetch the ${script}.js. The script might not exist in the requested version (status code: ${response.statusCode}).`
143+
`Could not fetch the ${script}.js. The script might not exist in the requested version (status code: ${response.statusCode}).`,
144+
500
144145
).setError(response);
145146
} else {
146147
log(
@@ -186,9 +187,10 @@ export const fetchScripts = async (
186187
port: proxyPort
187188
});
188189
} catch (error) {
189-
throw new ExportError('[cache] Could not create a Proxy Agent.').setError(
190-
error
191-
);
190+
throw new ExportError(
191+
'[cache] Could not create a Proxy Agent.',
192+
500
193+
).setError(error);
192194
}
193195
}
194196

@@ -270,7 +272,8 @@ export const updateCache = async (
270272
return fetchedModules;
271273
} catch (error) {
272274
throw new ExportError(
273-
'[cache] Unable to update the local Highcharts cache.'
275+
'[cache] Unable to update the local Highcharts cache.',
276+
500
274277
).setError(error);
275278
}
276279
};

lib/chart.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export const startExport = async (settings, endCallback) => {
114114
);
115115
} catch (error) {
116116
return endCallback(
117-
new ExportError('[chart] Error loading raw input.').setError(error)
117+
new ExportError('[chart] Error loading raw input.', 400).setError(error)
118118
);
119119
}
120120
}
@@ -527,6 +527,15 @@ const exportAsString = (stringToExport, options, endCallback) => {
527527
// Try to parse to JSON and call the doExport function
528528
const chartJSON = JSON.parse(stringToExport.replaceAll(/\t|\n|\r/g, ' '));
529529

530+
if (!chartJSON || typeof chartJSON !== 'object') {
531+
return endCallback(
532+
new ExportError(
533+
'[chart] Invalid configuration provided - the options must be an object, not a string',
534+
400
535+
)
536+
);
537+
}
538+
530539
// If a correct JSON, do the export
531540
return doExport(options, chartJSON, endCallback);
532541
} catch (error) {

0 commit comments

Comments
 (0)