Step 2 of GetStackString currently uses ToString to get the prelude of the stack.
However it seems the implementations that currently include the error description in the stack string currently defer to Error.prototype.toString and ignore any custom toString override, which the ToString steps would trigger.
It would likely be closer to reality to use Error.prototype.toString instead.
Test case
// First line
const err = Error('my message');
err.name = 'CustomError';
err.toString = () => 'overriden';
print(err.stack);
Result
#### JavaScriptCore
global code@/tmp/dxsvy0KPDOBv4jrOpdgh/f-1696257339837-28118-1yi6mn0.k8kil.js:2:2209
#### Moddable XS
CustomError: my message
at (/tmp/dMm7rKXjWXf5K5xEdYnV/f-1696257339789-28118-i6w9sl.3wpxp.js:16)
#### SpiderMonkey
@/tmp/pCYM45AKy8tqTPAUQyR2/f-1696257339847-28118-121pjez.xowej.js:2:8082
#### V8
CustomError: my message
at /tmp/cE6Ctkgb01qscSWukwO2/f-1696257339814-28118-1dh041b.2iyq.js:2:5903
Step 2 of
GetStackString
currently usesToString
to get the prelude of the stack.However it seems the implementations that currently include the error description in the stack string currently defer to
Error.prototype.toString
and ignore any customtoString
override, which theToString
steps would trigger.It would likely be closer to reality to use
Error.prototype.toString
instead.Test case
Result