Sometimes, calling JS_ToCString(ctx, val) where val is an instance of InternalError returns an empty string. Not very helpful when the exception object does in fact have a .message property with a human-readable error message.
Probably happens when there is a pending exception. Deep down, quickjs tries to invoke the [Symbol.toPrimitive] method but I doubt that works while an exception is pending.
Let's make debugging a little less miserable and special-case exception objects.
Sometimes, calling
JS_ToCString(ctx, val)wherevalis an instance ofInternalErrorreturns an empty string. Not very helpful when the exception object does in fact have a.messageproperty with a human-readable error message.Probably happens when there is a pending exception. Deep down, quickjs tries to invoke the
[Symbol.toPrimitive]method but I doubt that works while an exception is pending.Let's make debugging a little less miserable and special-case exception objects.