retrace
retrace copied to clipboard
Provide more informative errors
This is a great tool BTW.
We have put in a work-around to fix the lack of informative errors. Should be self-explanatory:
// Re-trace simply crashes at random points if the stack is not valid
// Try to provide a more detailed error message
if (error.message === '"version" is a required argument.') {
throw new Error(`The source map is not valid or the domain URL is incorrect; Used URL: ${sourceUrl}. Original Error:\n${error.message}`);
}
else if (error.message === 'Response code 400 (Bad Request)') {
if (minifiedStack.includes(' (<anonymous>)')) {
throw new Error(`Invalid Stack: Try removing line '(<anonymous>)'`);
}
}
else if (native.string.startsWith(error.message, 'Protocol')) {
if (minifiedStack.split('\n')[0].includes(':')) {
throw new Error(`Invalid Stack: The first line resembles a URL. Try removing all colons.\nOriginal Error:\n${error.message}`);
}
}
It will be great to have this handled by the library itself as the hack above doesn't really work in all cases.