-
Notifications
You must be signed in to change notification settings - Fork 1
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
use pcall #5
Comments
In the above, using this actually fixes my immediate problem, in pcall(function() REST.retrieve(dt) end) So, I can just do that if this doesn't seem like a good idea for the lib. |
Yea, it doesn't seem to be a nice idea. But I do wish to fix that bug either, if I'm not null checking it is because I didn't stumble on that error, can you create a minimal example on that issue? |
It's not a specific bug, as it will crash a love program on any error. For example, to recreate above, you'd need to run a web-server that resets the connection on too many requests (in my thing, I am using bettercap as the REST server.) I see the general problem of crashing a love-game on a bad request as the issue, not a specific type of failed request. As I said, I could just wrap all your stuff in As a related-sidenote, I really recommend some simple examples in README. I had to go work this out from my code, which I made guessing from the source of your lib. I'd be happy to add them in a PR, even if I don't use this lib. |
So, the main problem is basically indexing a nil value. It could be null checked that part, unless there are even more bugs like that. If you wish to do a PR, you're welcome |
That may be where we disagree. Like it is for this one thing, but other edge error cases would cause the same problem. Again, I am fine with wrapping your stuff with In any programming language that has a kind of fatal error (like lua) you can take an "always throw" approach to errors (and handle all errors non-fatally, which in the case of lua is with Again, since I am not going to use this library, after all, it makes less sense for me to fix it, especially if it doesn't seem like a problem in the first place, to you. I will PR for the examples, though, as this seems like a simple thing, and I already wrote code for it. |
It might be helpful and make it a bit easier to use if this lib wrapped network calls in pcall and returned
nil
on fail, or some other method of telling caller it didn't work out than an exception. Currently, if there is an error you get stuff like this, unless you wrap it yourself:It may be a bit more involved than just
nil
, like in this case I think the issue is a socket-reset (I am making too many requests in an update-loop.)maybe if it returned
response, error
? In that case, you could ignoreerror
if you wanted to, and it would work essentially the same.The text was updated successfully, but these errors were encountered: