Boa: `ReferenceError` on cli prints full obj properties instead of short message

Created on 18 Jun 2020  路  3Comments  路  Source: boa-dev/boa

On the cli, simply running ReferenceError, console, console.log and many other global objects/functions prints the full object and its properties of what the script returns instead of a short message like function: ReferenceError or global object: console.

to reproduce

Run console, console.log, ReferenceError on the cli

Expected behavior
Print a shorter description like function: ReferenceError or global object: console

The spec define not defineewhat to /how to print what the script returns.

Build environment (please complete the following information):

  • OS: [Windows10]
  • Version: [e.g. 64]
  • Target triple: [x86_64-uwp-windows-msvc]
  • Rustc version: [rustc 1.44.0 (49cae5576 2020-06-01)]
enhancement discussion cli

Most helpful comment

We should have a discussion on how to print the objects and errors (uncaught errors) we are not bound by the spec so we can print whatever we want!

Maybe the objects should be printed like: ObjectName { MaybeValueOrEmpty }, for example:

new String("Hello") // => String { "Hello" }
new Boolean(true) // => Boolean { true }
new UserDefinedClass() // => UserDefinedClass { }

For uncaught errors:

new TypeError(msg) // => Uncaught TypeError: msg (maybe in red)
throw "Hello"; // =>  Uncaught "Hello" (this is how node REPL does it)

What do you think? How can we improve it?

All 3 comments

We should have a discussion on how to print the objects and errors (uncaught errors) we are not bound by the spec so we can print whatever we want!

Maybe the objects should be printed like: ObjectName { MaybeValueOrEmpty }, for example:

new String("Hello") // => String { "Hello" }
new Boolean(true) // => Boolean { true }
new UserDefinedClass() // => UserDefinedClass { }

For uncaught errors:

new TypeError(msg) // => Uncaught TypeError: msg (maybe in red)
throw "Hello"; // =>  Uncaught "Hello" (this is how node REPL does it)

What do you think? How can we improve it?

Additionally we could have a flag for displaying all the object properties like we do now for debugging purposes.

Sound great to me. Perhaps for uncaught Errors we could print the stack trace also? (maybe just 2-3 levels of it on the cli for brevity).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasonwilliams picture jasonwilliams  路  6Comments

jasonwilliams picture jasonwilliams  路  4Comments

hello2dj picture hello2dj  路  5Comments

Razican picture Razican  路  4Comments

jasonwilliams picture jasonwilliams  路  6Comments