devices/utils/
error.rs

1// Copyright 2018 The ChromiumOS Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use base::Error as SysError;
6use remain::sorted;
7use thiserror::Error;
8
9#[sorted]
10#[derive(Error, Debug)]
11pub enum Error {
12    #[error("failed to create event: {0}")]
13    CreateEvent(SysError),
14    #[error("failed to create poll context: {0}")]
15    CreateWaitContext(SysError),
16    #[error("event loop already failed due to previous errors")]
17    EventLoopAlreadyFailed,
18    #[error("attempted to resume polling descriptor without handler")]
19    EventLoopMissingHandler,
20    #[error("failed to read event: {0}")]
21    ReadEvent(SysError),
22    #[error("failed to start thread: {0}")]
23    StartThread(std::io::Error),
24    #[error("failed to add fd to poll context: {0}")]
25    WaitContextAddDescriptor(SysError),
26    #[error("failed to delete fd from poll context: {0}")]
27    WaitContextDeleteDescriptor(SysError),
28    #[error("failed to write event: {0}")]
29    WriteEvent(SysError),
30}
31
32pub type Result<T> = std::result::Result<T, Error>;