2018-05-09 12:15:58 +03:00
|
|
|
// Copyright 2018 The Grin Developers
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
//! Wallet lib errors
|
|
|
|
|
2018-05-24 18:27:26 +03:00
|
|
|
use core::core::transaction;
|
2018-05-09 12:15:58 +03:00
|
|
|
use keychain::{self, extkey};
|
2018-05-24 18:27:26 +03:00
|
|
|
use util::secp;
|
2018-05-09 12:15:58 +03:00
|
|
|
|
2018-05-24 18:27:26 +03:00
|
|
|
#[derive(Fail, PartialEq, Clone, Debug)]
|
|
|
|
/// Libwallet error types
|
2018-05-09 12:15:58 +03:00
|
|
|
pub enum Error {
|
2018-05-24 18:27:26 +03:00
|
|
|
/// SECP error
|
|
|
|
#[fail(display = "Secp Error")]
|
2018-05-09 12:15:58 +03:00
|
|
|
Secp(secp::Error),
|
2018-05-24 18:27:26 +03:00
|
|
|
/// Keychain error
|
|
|
|
#[fail(display = "Keychain Error")]
|
2018-05-09 12:15:58 +03:00
|
|
|
Keychain(keychain::Error),
|
2018-05-24 18:27:26 +03:00
|
|
|
/// Extended key error
|
|
|
|
#[fail(display = "Extended Key Error")]
|
2018-05-09 12:15:58 +03:00
|
|
|
ExtendedKey(extkey::Error),
|
2018-05-24 18:27:26 +03:00
|
|
|
/// Transaction error
|
|
|
|
#[fail(display = "Transaction Error")]
|
|
|
|
Transaction(transaction::Error),
|
|
|
|
/// Signature error
|
|
|
|
#[fail(display = "Signature Error")]
|
|
|
|
Signature(String),
|
|
|
|
/// Rangeproof error
|
|
|
|
#[fail(display = "Rangeproof Error")]
|
2018-05-09 12:15:58 +03:00
|
|
|
RangeProof(String),
|
2018-05-24 18:27:26 +03:00
|
|
|
/// Fee error
|
|
|
|
#[fail(display = "Fee Error")]
|
|
|
|
Fee(String),
|
2018-05-09 12:15:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<secp::Error> for Error {
|
|
|
|
fn from(e: secp::Error) -> Error {
|
|
|
|
Error::Secp(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<extkey::Error> for Error {
|
|
|
|
fn from(e: extkey::Error) -> Error {
|
|
|
|
Error::ExtendedKey(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<keychain::Error> for Error {
|
|
|
|
fn from(e: keychain::Error) -> Error {
|
|
|
|
Error::Keychain(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-24 18:27:26 +03:00
|
|
|
impl From<transaction::Error> for Error {
|
|
|
|
fn from(e: transaction::Error) -> Error {
|
|
|
|
Error::Transaction(e)
|
2018-05-09 12:15:58 +03:00
|
|
|
}
|
2018-05-24 18:27:26 +03:00
|
|
|
}
|