A lot of current C++ code does not properly check for JS error, or report them.
As a sub-problem, a fair amount of code actually mangles JS error and messages are not being shown to the user.
Further, SM52 removes the ErrorReporter (it comes back in future versions, I believe).
This is thus the right time to update things slightly.
This improves the situation by:
- Checking for pending exceptions after function calls and script executions
- Calling LOGERROR instead of JS_ReportError when there is a conversion error in FromJSVal, since that can only be called from C++ (where JS errors don't really make sense). Instead, C++ callers of FromJSVal should handle the failure and, themselves, either report an error or simply do something else.
This isn't a systematical fix since ToJSVal also ought return a boolean for failures, and we probably should trigger errors instead of warnings on 'implicit' conversions.
Also wrap JS_ReportError since that makes updating it later easier.
See also debate on rP23773.
Based on a patch by @Itms, but somewhat reworked.
Part of the SM52 migration, stage: SM45 compatible (actually SM52 incompatible, too).