Skip to content

Commit

Permalink
fix: Fix message when permission denied to use cloud service (#2194)
Browse files Browse the repository at this point in the history
  • Loading branch information
karolisg authored Oct 27, 2023
1 parent 56b1372 commit 18f0b08
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion dozer-cli/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use glob::{GlobError, PatternError};
use std::io;
use std::path::PathBuf;
use std::string::FromUtf8Error;
use tonic::Code;
use tonic::Code::NotFound;

use crate::{
Expand Down Expand Up @@ -142,7 +143,7 @@ pub enum CloudError {
#[error("Connection failed. Error: {0:?}")]
ConnectionToCloudServiceError(#[from] tonic::transport::Error),

#[error("Cloud service returned error: {}", .0.message())]
#[error("Cloud service returned error: {}", map_status_error_message(.0.clone()))]
CloudServiceError(#[from] tonic::Status),

#[error("GRPC request failed, error: {} (GRPC status {})", .0.message(), .0.code())]
Expand Down Expand Up @@ -290,3 +291,12 @@ pub enum CloudContextError {
#[error("App id already exists. If you want to create a new app, please remove your cloud configuration")]
AppIdAlreadyExists(String),
}

fn map_status_error_message(status: tonic::Status) -> String {
match status.code() {
Code::PermissionDenied => {
"Permission denied. Please check your credentials and try again.".to_string()
}
_ => status.message().to_string(),
}
}

0 comments on commit 18f0b08

Please sign in to comment.