Commit 78f182fa authored by Michael Aaron Murphy's avatar Michael Aaron Murphy

Add additional error context to orbital-core

parent dc79e26d
Pipeline #3447 passed with stage
in 1 minute and 31 seconds
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "adler32"
version = "1.0.3"
......@@ -11,33 +13,6 @@ dependencies = [
"nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "autocfg"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "backtrace"
version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "backtrace-sys"
version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bitflags"
version = "0.7.0"
......@@ -48,11 +23,6 @@ name = "byteorder"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cc"
version = "1.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cfg-if"
version = "0.1.6"
......@@ -117,21 +87,13 @@ dependencies = [
]
[[package]]
name = "failure"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "failure_derive"
name = "err-derive"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.26 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -304,7 +266,7 @@ dependencies = [
name = "orbital"
version = "0.1.0"
dependencies = [
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"err-derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"orbclient 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
"orbfont 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"orbital-core 0.1.0",
......@@ -318,7 +280,7 @@ dependencies = [
name = "orbital-core"
version = "0.1.0"
dependencies = [
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"err-derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
"orbclient 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
"orbimage 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -440,9 +402,12 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc-demangle"
version = "0.1.13"
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rusttype"
......@@ -485,6 +450,19 @@ dependencies = [
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde"
version = "0.9.15"
......@@ -595,12 +573,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c"
"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71"
"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
"checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5"
"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
"checksum byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a019b10a2a7cdeb292db131fc8113e57ea2a908f6e7894b0c3c671893b65dbeb"
"checksum cc 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)" = "4390a3b5f4f6bce9c1d0c00128379df433e53777fdd30e92f16a529332baec4e"
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
"checksum color_quant 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0dbbb57365263e881e805dc77d94697c9118fd94d8da011240555aa7b23445bd"
"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
......@@ -609,8 +583,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum deflate 0.7.19 (registry+https://github.com/rust-lang/crates.io-index)" = "8a6abb26e16e8d419b5c78662aa9f82857c2386a073da266840e474d5055ec86"
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180"
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
"checksum err-derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3d8ff65eb6c2fc68e76557239d16f5698fd56603925b89856d3f0f7105fd4543"
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
"checksum gif 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e41945ba23db3bf51b24756d73d81acb4f28d85c3dccc32c6fae904438c25f"
"checksum image 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d95816db758249fe16f23a4e23f1a3a817fe11892dbfd1c5836f625324702158"
......@@ -647,12 +620,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum redox_event 0.1.0 (git+https://github.com/redox-os/event.git)" = "<none>"
"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85"
"checksum resize 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e8f5c5cf4d79776ed121e1c5052718b4bb06d2b48049144a2f0e5ad613b608e"
"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum rusttype 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "30047cc747a78ae042bf2cd65c79f83c3485d90107535b532d6e8f60e2c89cb1"
"checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum sdl2 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a74c2a98a354b20713b90cce70aef9e927e46110d1bc4ef728fd74e0d53eba60"
"checksum sdl2-sys 0.31.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5c543ce8a6e33a30cb909612eeeb22e693848211a84558d5a00bb11e791b7ab7"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum serde 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)" = "34b623917345a631dc9608d5194cc206b3fe6c3554cd1c75b937e55e285254af"
"checksum serde_codegen_internals 0.14.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bc888bd283bd2420b16ad0d860e35ad8acb21941180a83a189bb2046f9d00400"
"checksum serde_derive 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)" = "978fd866f4d4872084a81ccc35e275158351d3b9fe620074e7d7504b816b74ba"
......
......@@ -8,13 +8,13 @@ repository = "https://gitlab.redox-os.org/redox-os/orbital"
version = "0.1.0"
[dependencies]
failure = "0.1.1"
orbclient = "0.3"
orbfont = "0.1"
redox_syscall = "0.1"
serde = "0.9"
serde_derive = "0.9"
toml = "0.3"
err-derive = "0.1.5"
[dependencies.orbital-core]
path = "orbital-core"
......@@ -6,11 +6,11 @@ repository = "https://github.com/redox-os/orbital"
version = "0.1.0"
[dependencies]
failure = "0.1.1"
libc = "0.2.48"
orbclient = "0.3"
orbimage = "0.1"
redox_syscall = "0.1"
err-derive = "0.1.5"
[dependencies.redox_event]
git = "https://github.com/redox-os/event.git"
#[macro_use] extern crate failure;
#[macro_use] extern crate err_derive;
extern crate event;
extern crate libc;
extern crate orbclient;
......@@ -32,17 +32,31 @@ use syscall::{
flag::{O_CLOEXEC, O_CREAT, O_NONBLOCK, O_RDWR}
};
#[derive(Debug, Fail)]
pub enum Error {
#[fail(display = "io error: {}", _0)]
#[derive(Debug, Error)]
pub enum Error<'a> {
#[error(display = "failed to open display path at '{}': {}", display_path, why)]
DisplayPath { display_path: &'a str, why: io::Error },
#[error(display = "unable to add {} event to event queue: {}", desc, why)]
EventQueueAdd { desc: &'static str, why: io::Error },
#[error(display = "unable to get event queue: {}", _0)]
EventQueueNew(io::Error),
#[error(display = "failed to run event queue: {}", _0)]
EventQueueRun(io::Error),
#[error(display = "failed to trigger all events for {:?}: {}", event, why)]
EventQueueTrigger { event: event::Event, why: io::Error },
#[error(display = "io error: {}", _0)]
IoError(io::Error),
#[fail(display = "syscall error: {}", _0)]
#[error(display = "failed to open orbital scheme: {}", _0)]
OrbitalScheme(io::Error),
#[error(display = "failed to startup handler: {}", _0)]
Startup(io::Error),
#[error(display = "syscall error: {}", _0)]
SyscallError(syscall::Error),
}
impl From<io::Error> for Error {
impl<'a> From<io::Error> for Error<'a> {
fn from(err: io::Error) -> Self { Error::IoError(err) }
}
impl From<syscall::Error> for Error {
impl<'a> From<syscall::Error> for Error<'a> {
fn from(err: syscall::Error) -> Self { Error::SyscallError(err) }
}
......@@ -152,7 +166,7 @@ pub struct Orbital {
}
impl Orbital {
/// Open an orbital display and connect to the scheme
pub fn open_display(display_path: &str) -> io::Result<Self> {
pub fn open_display(display_path: &str) -> Result<Self, Error> {
let scheme = syscall::open(":orbital", O_CREAT | O_CLOEXEC | O_NONBLOCK | O_RDWR)
.map(|socket| {
// Not that you can actually use this on targets other than redox...
......@@ -162,7 +176,8 @@ impl Orbital {
unsafe { File::from_raw_fd(socket) }
})
.map_err(|err| io::Error::from_raw_os_error(err.errno))?;
.map_err(|err| io::Error::from_raw_os_error(err.errno))
.map_err(Error::OrbitalScheme)?;
let display = syscall::open(&display_path, O_CLOEXEC | O_NONBLOCK | O_RDWR)
.map(|socket| {
......@@ -173,7 +188,8 @@ impl Orbital {
unsafe { File::from_raw_fd(socket) }
})
.map_err(|err| io::Error::from_raw_os_error(err.errno))?;
.map_err(|err| io::Error::from_raw_os_error(err.errno))
.map_err(|why| Error::DisplayPath { display_path, why })?;
let display_fd = display.as_raw_fd();
......@@ -199,6 +215,7 @@ impl Orbital {
height: height
})
}
/// Write an Event to display I/O
pub fn display_write(&mut self, event: &Event) -> io::Result<()> {
self.display.write(event).map(|_| ())
......@@ -231,23 +248,25 @@ impl Orbital {
}
}
/// Start the main loop
pub fn run<H>(mut self, mut handler: H) -> Result<(), Error>
pub fn run<'a, H>(mut self, mut handler: H) -> Result<(), Error<'a>>
where H: Handler + 'static
{
let mut event_queue = EventQueue::<()>::new()?;
let mut event_queue = EventQueue::<()>::new()
.map_err(Error::EventQueueNew)?;
syscall::setrens(0, 0)?;
let scheme_fd = self.scheme.as_raw_fd();
let display_fd = self.display.as_raw_fd();
handler.handle_startup(&mut self)?;
handler.handle_startup(&mut self)
.map_err(Error::Startup)?;
let me = Rc::new(RefCell::new(OrbitalHandler {
orb: self,
handler: handler,
}));
let me2 = Rc::clone(&me);
let me2 = me.clone();
event_queue.add(scheme_fd, move |_| -> io::Result<Option<()>> {
let mut me = me.borrow_mut();
......@@ -278,7 +297,7 @@ impl Orbital {
Ok(None)
})?;
event_queue.add(display_fd, move |_| -> io::Result<Option<()>> {
let display_func = move |_| -> io::Result<Option<()>> {
let mut me = me2.borrow_mut();
let me = &mut *me;
let mut events = [Event::new(); 16];
......@@ -311,13 +330,20 @@ impl Orbital {
me.handler.handle_display_after(&mut me.orb)?;
me.handler.handle_after(&mut me.orb)?;
Ok(None)
})?;
};
event_queue.add(display_fd, display_func)
.map_err(|why| Error::EventQueueAdd { desc: "display", why })?;
event_queue.trigger_all(event::Event {
let event = event::Event {
fd: 0,
flags: 0,
})?;
event_queue.run()?;
};
event_queue.trigger_all(event)
.map_err(|why| Error::EventQueueTrigger { event, why })?;
event_queue.run().map_err(Error::EventQueueRun)?;
Ok(())
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment