1 // Copyright 2024 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 5 use std::io::Error as IOError; 6 7 use remain::sorted; 8 use thiserror::Error; 9 10 use crate::utils::Error as UtilsError; 11 12 #[sorted] 13 #[derive(Error, Debug)] 14 pub enum Error { 15 #[error("Failed to arm {name} timer: {error:#}")] 16 CannotArmPollTimer { name: String, error: base::Error }, 17 #[error("Failed to clear {name} timer: {error:#}")] 18 CannotClearPollTimer { name: String, error: base::Error }, 19 #[error("Cannot convert the u2f init packet from bytes")] 20 CannotConvertInitPacketFromBytes, 21 #[error("Cannot create the poll timer")] 22 CannotCreatePollTimer(base::Error), 23 #[error("Cannot extract cid value from packet bytes")] 24 CannotExtractCidFromBytes, 25 #[error("Pending fido transfer reference has been lost.")] 26 FidoTransferLost, 27 #[error("The fido device is in an inconsistent state")] 28 InconsistentFidoDeviceState, 29 #[error("Invalid data buffer size")] 30 InvalidDataBufferSize, 31 #[error("The given hidraw device is not a security key")] 32 InvalidHidrawDevice, 33 #[error("The u2f init packet is invalid")] 34 InvalidInitPacket, 35 #[error("The u2f init packet contains invalid data size for the nonce")] 36 InvalidNonceSize, 37 #[error("Pending packet queue is full and cannot process more host packets")] 38 PendingInQueueFull, 39 #[error("Failed to read packet from hidraw device")] 40 ReadHidrawDevice(IOError), 41 #[error("Cannot start fido device queue")] 42 StartAsyncFidoQueue(UtilsError), 43 #[error("Unsupported TransferBuffer type")] 44 UnsupportedTransferBufferType, 45 #[error("Failed to wait context on poll thread")] 46 WaitContextFailed(anyhow::Error), 47 #[error("Failed to write to hidraw device")] 48 WriteHidrawDevice(IOError), 49 } 50 51 pub type Result<T> = std::result::Result<T, Error>; 52