Comments (3)
Yes, this is an unfortunate early design decision and I'd like to change it eventually. Along with returning (return-value, error-string, error-code) instead of (return-value, error-code).
Every socket has an error handler. The default error handler will throw an error for everything except EPIPE and ETIMEDOUT. The idea was that errors would be thrown, except that EPIPE and ETIMEDOUT weren't errors and would usually be handled inline. This is described in the socket:onerror method documentation, and the introduction section on Errors also has a blurb about it (I should make it more explicit). I now find the current default behavior really quite annoying. The original impetus--keep applications from accidentally ignoring errors--is no longer relevant, because errors are repeated until cleared, and will eventually throw after a user-defined count of unsuccessful operations if the error hadn't been cleared.
You can change the current behavior by changing the default error handler using socket.onerror, which is a method on the prototype singleton. All subsequent sockets will then use that error handler.
from cqueues.
Thanks for the note; I didn't realise that was what socket.onerror
was for.
This seems a much more reasonable default (at least to me):
local cqueues_socket = require "cqueues.socket"
local cqueues_errno = require "cqueues.errno"
-- Change default error handler to *not* throw.
cqueues_socket.onerror(function(sock, func, errno, level)
local msg = cqueues_errno.strerror(errno)
return msg, errno
end)
from cqueues.
On Wed, Oct 22, 2014 at 09:41:30AM -0700, daurnimator wrote:
Thanks for the note; I didn't realise that was what
socket.onerror
was for.This seems a much more reasonable default (at least to me):
-- Change default error handler to *not* throw. cqueues_socket.onerror(function(sock, func, errno, level) local msg = cqueues_errno.strerror(errno) return msg, errno end)
I agree it makes more sense. Eventually I want to have a flag day where I
change the default to the above, not just for sockets but for all modules.
But that'll require some planning and a careful refactoring of everything,
including making it easy to get the old behavior, as there's too much code
in production at this point.
FWIW, auxlib.fileresult will convert the existing return values to the more
idiomatic Lua return values.
I've opened two new issues to fix this stuff. You can keep #8 open if you
want.
from cqueues.
Related Issues (20)
- ERROR: cqueue: attempt to yield across metamethod/C-call boundary HOT 6
- Consider removing the debian/ dir (or moving it to another place) HOT 1
- error thrown from sleep: attempt to call a userdata value HOT 3
- installing on debian 9 using luarocks 3.3 with lua 5.1 fails HOT 2
- The codes are so urgly!
- lua 5.1 can import cqueues, luajit cannot HOT 1
- lua 5.3 build failed HOT 1
- Lua 5.4 support HOT 1
- cqueues unusable on aarch64 under LuaJIT HOT 21
- cqueues.notify: removing file from notify object
- cqueues.lua:85 expected 1 arguments, got 5 HOT 4
- Nesting controllers / parent discovery HOT 2
- Luarocks install fails on arm64 mac HOT 4
- starttls issue (unable to update event disposition: No such file or directory) HOT 4
- cqueues fails install within a Docker image; states 5.2-1 version is provided, when 5.2 is required HOT 2
- Does not build on raspbian HOT 5
- undefined symbol:CRYPTO_set_locking_callback HOT 2
- Working on the arm-linux board , and the compile is so complex HOT 1
- Does not build on OpenBSD 7.2
- cqueues doesn't work on FreeBSD 13.1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cqueues.