Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repl: Fix error() calls with a non-string message breaking the repl #899

Merged
merged 1 commit into from
May 20, 2016

Conversation

squeek502
Copy link
Member

Fixes #898

error() calls with non-string messages will now output the following:

Welcome to the Luvit repl!
> error(function() end)
error with unexpected error message type (function), no stacktrace available
> error()
error with unexpected error message type (nil), no stacktrace available

Let me know if you think there's a better way to handle this, or if the message could be made clearer.

Fixes luvit#898

`error()` calls with non-string messages will now output the following:

```
Welcome to the Luvit repl!
> error(function() end)
error with unexpected error message type (function), no stacktrace available
> error()
error with unexpected error message type (nil), no stacktrace available
```
@creationix
Copy link
Member

Maybe instead of the type, run the value through tostring?

@squeek502
Copy link
Member Author

Using tostring would be largely the same except in the case of boolean, where the output would be something like error with unexpected error message type (false), no stacktrace available, which seems like it could be confusing.

I'm not sure there's much benefit to displaying the value, but I'll leave it up to you.

For reference, here's what the plain Lua 5.1.5 repl outputs (note that error() is totally silent):

Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> error()
> error(false)
(error object is not a string)
> error(function() end)
(error object is not a string)

@creationix creationix merged commit 29b958a into luvit:master May 20, 2016
zhaozg pushed a commit to zhaozg/luvit that referenced this pull request Apr 2, 2019
repl: Fix error() calls with a non-string message breaking the repl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants