Re-add improved error messages with fixes #784
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a fixed version of the original PR (#717). It caused errors in projects that people had already made. This version has been tested on every project in the gallery, as well as every open PR, and every issue has been solved.
Summary of the affected projects
Gallery projects
Open PRs
Original description (from #717)
This PR improves error messages significantly:

Before this change:
![Line 0: undefined is not a function (near '...[o,u]...')](https://private-user-images.githubusercontent.com/167175925/350134341-8bfef329-4530-485f-b0c5-6a96f6337746.jpeg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDAxMjI4ODgsIm5iZiI6MTc0MDEyMjU4OCwicGF0aCI6Ii8xNjcxNzU5MjUvMzUwMTM0MzQxLThiZmVmMzI5LTQ1MzAtNDg1Zi1iMGM1LTZhOTZmNjMzNzc0Ni5qcGVnP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIyMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMjFUMDcyMzA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MzE2YjAxY2QxNzAxOTQ5OGIxZGZiYzk0N2RhY2E4ZGM4N2M5NDE5MjEyMWFkN2I2ZWE0NGI4YzhlMDM5NTZmOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.fzi4hv2jyoT6iJpRt2Ep8RFe9XTJW3Fi6HwvUtDedtI)
This adds assertations to all of the built-in functions in Blot to throw meaningful errors when the wrong arguments are passed. It also upgrades the stack trace parsing logic, using V8's object representation and a regex built based on the SpiderMonkey and JavaScriptCore source code. Safari (JavaScriptCore) does not keep track of line numbers within eval'd code, so a hack is used to construct a data URL and import it when it is detected to be nessesary.
The previous version of Blot would give unhelpful errors like "t is not defined" on line 0, and line numbers only ever worked on Chrome in some cases. Now, it will give helpful errors explaining what went wrong, pointing to the correct position in the code on any browser.
There is a known issue where, on Safari, the stack does not follow nesting, so if the user defines a function, the error will appear where the function is called instead of within the function, but
there is no way to fix this.