cfxcore_accounts/error.rs
1// Copyright 2015-2018 Parity Technologies (UK) Ltd.
2// This file is part of Parity.
3
4// Parity is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Parity is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Parity. If not, see <http://www.gnu.org/licenses/>.
16
17use std::fmt;
18
19use cfxstore::Error as SSError;
20
21/// Signing error
22#[derive(Debug)]
23pub enum SignError {
24 /// Account is not unlocked
25 NotUnlocked,
26 /// Account does not exist.
27 NotFound,
28 /// Low-level error from store
29 SStore(SSError),
30}
31
32impl fmt::Display for SignError {
33 fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
34 match *self {
35 SignError::NotUnlocked => write!(f, "Account is locked"),
36 SignError::NotFound => write!(f, "Account does not exist"),
37 SignError::SStore(ref e) => write!(f, "{}", e),
38 }
39 }
40}
41
42impl From<SSError> for SignError {
43 fn from(e: SSError) -> Self { SignError::SStore(e) }
44}