-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: concrete error type for Identity::new
- Loading branch information
1 parent
88cae61
commit 6041a9d
Showing
17 changed files
with
165 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/dfx-core/src/error/identity/get_identity_config_or_default.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use crate::error::structured_file::StructuredFileError; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum GetIdentityConfigOrDefaultError { | ||
#[error("Failed to load configuration for identity '{0}': {1}")] | ||
LoadIdentityConfigurationFailed(String, StructuredFileError), | ||
} |
15 changes: 15 additions & 0 deletions
15
src/dfx-core/src/error/identity/instantiate_identity_from_name.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use crate::error::identity::load_identity::LoadIdentityError; | ||
use crate::error::identity::IdentityError; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum InstantiateIdentityFromNameError { | ||
#[error("Failed to get principal of identity: {0}")] | ||
GetIdentityPrincipalFailed(String), | ||
|
||
#[error("Failed to load identity: {0}")] | ||
LoadIdentityFailed(LoadIdentityError), | ||
|
||
#[error("Identity must exist: {0}")] | ||
RequireIdentityExistsFailed(IdentityError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use crate::error::identity::get_identity_config_or_default::GetIdentityConfigOrDefaultError; | ||
use crate::error::identity::new_identity::NewIdentityError; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum LoadIdentityError { | ||
#[error("Failed to get identity config: {0}")] | ||
GetIdentityConfigOrDefaultFailed(GetIdentityConfigOrDefaultError), | ||
|
||
#[error("Failed to instantiate identity: {0}")] | ||
NewIdentityFailed(NewIdentityError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use crate::error::identity::load_pem_from_file::LoadPemFromFileError; | ||
use crate::error::keyring::KeyringError; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum LoadPemError { | ||
#[error("Failed to load PEM file from file : {0}")] | ||
LoadFromFileFailed(LoadPemFromFileError), | ||
|
||
#[error("Failed to load PEM file from keyring for identity '{0}': {1}")] | ||
LoadFromKeyringFailed(Box<String>, KeyringError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use crate::error::encryption::EncryptionError; | ||
use crate::error::fs::FsError; | ||
use std::path::PathBuf; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum LoadPemFromFileError { | ||
#[error("Failed to decrypt PEM file: {0}")] | ||
DecryptPemFileFailed(PathBuf, EncryptionError), | ||
|
||
#[error("Failed to read pem file: {0}")] | ||
ReadPemFileFailed(FsError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use ic_agent::identity::PemError; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum LoadPemIdentityError { | ||
#[error("Cannot read identity file '{0}': {1:#}")] | ||
ReadIdentityFileFailed(String, Box<PemError>), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use ic_identity_hsm::HardwareIdentityError; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum NewHardwareIdentityError { | ||
#[error("Failed to instantiate hardware identity for identity '{0}': {1}.")] | ||
InstantiateHardwareIdentityFailed(String, Box<HardwareIdentityError>), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use crate::error::identity::load_pem::LoadPemError; | ||
use crate::error::identity::load_pem_identity::LoadPemIdentityError; | ||
use crate::error::identity::new_hardware_identity::NewHardwareIdentityError; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum NewIdentityError { | ||
#[error("Failed to load PEM: {0}")] | ||
LoadPemFailed(LoadPemError), | ||
|
||
#[error("Failed to load PEM identity: {0}")] | ||
LoadPemIdentityFailed(LoadPemIdentityError), | ||
|
||
#[error("Failed to instantiate hardware identity: {0}")] | ||
NewHardwareIdentityFailed(NewHardwareIdentityError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.