working basic flow
This commit is contained in:
@@ -58,6 +58,8 @@ pub enum RequestError {
|
||||
RequestTooLarge,
|
||||
NoCredentials(GetCredentialsError),
|
||||
ClientInfo(ClientInfoError),
|
||||
Tauri(tauri::Error),
|
||||
NoMainWindow,
|
||||
}
|
||||
impl From<tokio::io::Error> for RequestError {
|
||||
fn from(e: std::io::Error) -> RequestError {
|
||||
@@ -79,6 +81,11 @@ impl From<ClientInfoError> for RequestError {
|
||||
RequestError::ClientInfo(e)
|
||||
}
|
||||
}
|
||||
impl From<tauri::Error> for RequestError {
|
||||
fn from(e: tauri::Error) -> RequestError {
|
||||
RequestError::Tauri(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for RequestError {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> {
|
||||
@@ -92,6 +99,8 @@ impl Display for RequestError {
|
||||
NoCredentials(GetCredentialsError::Empty) => write!(f, "Received go-ahead but no credentials are known"),
|
||||
ClientInfo(ClientInfoError::PidNotFound) => write!(f, "Could not resolve PID of client process."),
|
||||
ClientInfo(ClientInfoError::NetstatError(e)) => write!(f, "Error getting client socket details: {e}"),
|
||||
Tauri(e) => write!(f, "Tauri error: {e}"),
|
||||
NoMainWindow => write!(f, "No main application window found"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,6 +111,26 @@ pub enum GetCredentialsError {
|
||||
Empty,
|
||||
}
|
||||
|
||||
pub type AwsTokenError = aws_sdk_sts::types::SdkError<aws_sdk_sts::error::GetSessionTokenError>;
|
||||
|
||||
pub enum GetSessionError {
|
||||
NoCredentials, // SDK returned successfully but credentials are None
|
||||
SdkError(AwsTokenError),
|
||||
}
|
||||
impl From<AwsTokenError> for GetSessionError {
|
||||
fn from(e: AwsTokenError) -> GetSessionError {
|
||||
GetSessionError::SdkError(e)
|
||||
}
|
||||
}
|
||||
impl Display for GetSessionError {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> {
|
||||
match self {
|
||||
GetSessionError::NoCredentials => write!(f, "Request completed successfully but no credentials were returned"),
|
||||
GetSessionError::SdkError(e) => write!(f, "Error response from AWS: {e}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub enum UnlockError {
|
||||
NotLocked,
|
||||
@@ -109,6 +138,7 @@ pub enum UnlockError {
|
||||
BadPassphrase,
|
||||
InvalidUtf8, // Somehow we got invalid utf-8 even though decryption succeeded
|
||||
DbError(SqlxError),
|
||||
GetSession(GetSessionError),
|
||||
}
|
||||
impl From<SqlxError> for UnlockError {
|
||||
fn from (e: SqlxError) -> UnlockError {
|
||||
@@ -118,6 +148,11 @@ impl From<SqlxError> for UnlockError {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl From<GetSessionError> for UnlockError {
|
||||
fn from(e: GetSessionError) -> UnlockError {
|
||||
UnlockError::GetSession(e)
|
||||
}
|
||||
}
|
||||
impl Display for UnlockError {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> {
|
||||
use UnlockError::*;
|
||||
@@ -127,6 +162,7 @@ impl Display for UnlockError {
|
||||
BadPassphrase => write!(f, "Invalid passphrase"),
|
||||
InvalidUtf8 => write!(f, "Decrypted data was corrupted"),
|
||||
DbError(e) => write!(f, "Database error: {e}"),
|
||||
GetSession(e) => write!(f, "Failed to create AWS session: {e}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user