Comments (5)
Yes, definitely. Notably, process_events()
should return a result that indicates, when an error occurred, if it came from the polling machinery itself or from one of the event sources, in which case it could be a Box<dyn Error>
. Probably worth thinking to some mechanism that allows to easily detect which source errored, to act upon that if possible/necessary.
from calloop.
Excellent, we can discuss the general approach here and then I'll code it up.
I tend to avoid Box<dyn Error>
- basically it doesn't do a whole lot that anyhow
or thiserror
don't achieve between them. Both of those libs will happily work with (ie. wrap, allow unwrapping, combine) errors that implement std::error::Error
, so we should be fine there.
My first suggestion would be to have a calloop::CalloopError
that
- implements
std::error::Error
- has
From
impls fromstd::io::Error
into itself- possibly has a few distinct types that correspond to obvious
std::io::ErrorKind
s without going overboard
- possibly has a few distinct types that correspond to obvious
- has
From
impls fromstd::error::Error
into itself - has enough additional information that the event source can at least be identified (access it directly might have ownership issues, because the loop owns the source, but eg. the handle's registration token or the source's token could be recorded)
Off the top of my head, we would also need a From
impl for std::result::Result
so that ?
works (because it can't automatically do Result<T, E>
into Result<S, F>
just because T: Into<S>
and E: Into<F>
).
I think we get a lot of that for free with thiserror
, so if you're not averse to adding that as a dependency, I'll use it. If not, I won't, but there might be extra boilerplate.
from calloop.
I'm fine with using thiserror
, but without Box<dyn Error>
we cannot allow the event sources to have their own custom error types. I thought that that was what you wanted?
from calloop.
Ah I see what you're saying. The significant part for me is not so much "event sources having custom error types" as "having error types that can easily be chained with ?
or maintain a traceback through the callbacks." I'm actually not sure how much a boxed error would have to proliferate, so maybe I should code something up and see what's possible?
from calloop.
Ah I see. I don't know how much of a necessity having custom error types for event sources is. But I guess we can still have a fancy calloop error type based on thiserror
, which a Custom(Box<dyn Error>)
variant for cases where the event source really needs it.
from calloop.
Related Issues (20)
- bug: epoll module is not imported if on #[cfg(target_os = "android")] HOT 2
- API: TransientSource requires the loop to run again before the source can be replaced HOT 5
- Advice on Metadata in EventSource of Timer HOT 6
- Can callback functions be nested? HOT 2
- Double borrows when registering sources and idle callbacks
- Repeating future gets stuck forever HOT 4
- Use kqueue `EVFILT_SIGNAL` to support signals on BSD HOT 4
- Unstable feature is used when checking coverage in upstream crate HOT 1
- Remove the thiserror dependency
- Allow event source to mark itself as being ready from the `pre_run` or similar HOT 5
- Non blocking event loop with calloop HOT 5
- Enforce IO safety HOT 6
- Calloop cannot be shared between objects safely HOT 6
- Storing registration token in structure HOT 2
- epoll timeout rounding logic is broken on 0.10.x HOT 1
- "Transient" source wrapper (includes channel CPU spike issue) HOT 6
- Add self-repeating timers
- Investigate non-deterministic timer test failure on macos HOT 11
- Enhancement: PostAction combinator HOT 2
- insert_source_no_interest fails if stdin is redirected HOT 3
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 calloop.