Skip to content

Commit

Permalink
Rison error handling (#4594)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Jan 14, 2023
1 parent 8462cc4 commit 3f9813a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions static/main.ts
Expand Up @@ -259,7 +259,16 @@ function configFromEmbedded(embeddedUrl: string) {
try {
params = url.unrisonify(embeddedUrl);
} catch (e) {
// Ignore this, it's not a problem
document.write(
'<div style="padding: 10px; background: #fa564e; color: black;">' +
"An error was encountered while decoding the URL for this embed. Make sure the URL hasn't been " +
'truncated, otherwise if you believe your URL is valid please let us know on ' +
'<a href="https://github.com/compiler-explorer/compiler-explorer/issues" style="color: black;">' +
'our github' +
'</a>.' +
'</div>'
);
throw new Error('Embed url decode error');
}
if (params && params.source && params.compiler) {
const filters = Object.fromEntries(((params.filters as string) || '').split(',').map(o => [o, true]));
Expand Down Expand Up @@ -335,13 +344,12 @@ function findConfig(defaultConfig: ConfigType, options: CompilerExplorerOptions)
} catch (e) {
// #3518 Alert the user that the url is invalid
const alertSystem = new Alert();
alertSystem.notify(
'Unable to load custom configuration from URL,\
the last locally saved configuration will be used if present.',
{
alertClass: 'notification-error',
dismissTime: 5000,
}
alertSystem.alert(
'Decode Error',
'An error was encountered while decoding the URL, the last locally saved configuration will ' +
"be used if present.<br/><br/>Make sure the URL you're using hasn't been truncated, " +
'otherwise if you believe your URL is valid please let us know on ' +
'<a href="https://github.com/compiler-explorer/compiler-explorer/issues">our github</a>.'
);
}
}
Expand Down

0 comments on commit 3f9813a

Please sign in to comment.