Skip to content

Commit

Permalink
rename errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcfrancisco committed Jul 24, 2024
1 parent 84f52c6 commit 21b4547
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub type Result<T> = core::result::Result<T, Error>;
#[derive(Debug, From)]
pub enum Error {
// -- utils
FailedInputValidation(String),
FailedValidation(String),
Mode(String),

// -- pg
Expand All @@ -15,7 +15,7 @@ pub enum Error {
// -- file_types
UnsupportedFileExtension(String),
UnsupportedShapeType(String),
ContainsMixedDataTypes(String),
MixedDataTypes(String),

// -- Externals
#[from]
Expand Down
6 changes: 3 additions & 3 deletions src/file_types/geojson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn determine_data_types(file_path: &str) -> Result<Vec<NewTableTypes>> {
} else if table_config.contains_key(&key)
&& table_config[&key] != Type::INT8
{
return Err(Error::ContainsMixedDataTypes("Column contains mixed data types ✘".to_string()));
return Err(Error::MixedDataTypes("Column contains mixed data types ✘".to_string()));
} else {
table_config.insert(key, Type::FLOAT8);
}
Expand All @@ -54,7 +54,7 @@ pub fn determine_data_types(file_path: &str) -> Result<Vec<NewTableTypes>> {
} else if table_config.contains_key(&key)
&& table_config[&key] != Type::INT8
{
return Err(Error::ContainsMixedDataTypes("Column contains mixed data types ✘".to_string()));
return Err(Error::MixedDataTypes("Column contains mixed data types ✘".to_string()));
} else {
table_config.insert(key, Type::TEXT);
}
Expand All @@ -67,7 +67,7 @@ pub fn determine_data_types(file_path: &str) -> Result<Vec<NewTableTypes>> {
} else if table_config.contains_key(&key)
&& table_config[&key] != Type::INT8
{
return Err(Error::ContainsMixedDataTypes("Column contains mixed data types ✘".to_string()));
return Err(Error::MixedDataTypes("Column contains mixed data types ✘".to_string()));
} else {
table_config.insert(key, Type::BOOL);
}
Expand Down
12 changes: 6 additions & 6 deletions src/file_types/shapefile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn determine_data_types(file_path: &str) -> Result<Vec<NewTableTypes>> {
} else if table_config.contains_key(&column_name)
&& table_config[&column_name] != Type::INT8
{
return Err(Error::ContainsMixedDataTypes("Column contains mixed data types ✘".to_string()));
return Err(Error::MixedDataTypes("Column contains mixed data types ✘".to_string()));
} else {
table_config.insert(column_name, Type::FLOAT8);
}
Expand All @@ -37,7 +37,7 @@ pub fn determine_data_types(file_path: &str) -> Result<Vec<NewTableTypes>> {
} else if table_config.contains_key(&column_name)
&& table_config[&column_name] != Type::INT8
{
return Err(Error::ContainsMixedDataTypes("Column contains mixed data types ✘".to_string()));
return Err(Error::MixedDataTypes("Column contains mixed data types ✘".to_string()));
} else {
table_config.insert(column_name, Type::FLOAT8);
}
Expand All @@ -50,7 +50,7 @@ pub fn determine_data_types(file_path: &str) -> Result<Vec<NewTableTypes>> {
} else if table_config.contains_key(&column_name)
&& table_config[&column_name] != Type::INT8
{
return Err(Error::ContainsMixedDataTypes("Column contains mixed data types ✘".to_string()));
return Err(Error::MixedDataTypes("Column contains mixed data types ✘".to_string()));
} else {
table_config.insert(column_name, Type::FLOAT8);
}
Expand All @@ -63,7 +63,7 @@ pub fn determine_data_types(file_path: &str) -> Result<Vec<NewTableTypes>> {
} else if table_config.contains_key(&column_name)
&& table_config[&column_name] != Type::FLOAT8
{
return Err(Error::ContainsMixedDataTypes("Column contains mixed data types ✘".to_string()));
return Err(Error::MixedDataTypes("Column contains mixed data types ✘".to_string()));
} else {
table_config.insert(column_name, Type::INT8);
}
Expand All @@ -76,7 +76,7 @@ pub fn determine_data_types(file_path: &str) -> Result<Vec<NewTableTypes>> {
} else if table_config.contains_key(&column_name)
&& table_config[&column_name] != Type::INT8
{
return Err(Error::ContainsMixedDataTypes("Column contains mixed data types ✘".to_string()));
return Err(Error::MixedDataTypes("Column contains mixed data types ✘".to_string()));
} else {
table_config.insert(column_name, Type::TEXT);
}
Expand All @@ -89,7 +89,7 @@ pub fn determine_data_types(file_path: &str) -> Result<Vec<NewTableTypes>> {
} else if table_config.contains_key(&column_name)
&& table_config[&column_name] != Type::INT8
{
return Err(Error::ContainsMixedDataTypes("Column contains mixed data types ✘".to_string()));
return Err(Error::MixedDataTypes("Column contains mixed data types ✘".to_string()));
} else {
table_config.insert(column_name, Type::BOOL);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn run() -> Result<()> {
}
_ => {
println!("Mode not supported ✘");
return Err(Error::FailedInputValidation("Mode not supported ✘".into()));
return Err(Error::FailedValidation("Mode not supported ✘".into()));
}
}
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ pub fn validate_args(args: &Cli) -> Result<()> {

// Check input file exists
if !Path::new(&args.input).exists() {
return Err(Error::FailedInputValidation("Input file does not exist ✘".into()));
return Err(Error::FailedValidation("Input file does not exist ✘".into()));
}

// Check URL is not empty
if args.uri.is_empty() {
return Err(Error::FailedInputValidation("URL is empty ✘".into()));
return Err(Error::FailedValidation("URL is empty ✘".into()));
}

// Check table is not empty
if args.table.is_empty() {
return Err(Error::FailedInputValidation("Table is empty ✘".into()));
return Err(Error::FailedValidation("Table is empty ✘".into()));
}

// Check if srid is 4326 or 3857
if let Some(srid) = args.srid {
if srid != 4326 && srid != 3857 {
return Err(Error::FailedInputValidation("SRID must be 4326 or 3857 ✘".into()));
return Err(Error::FailedValidation("SRID must be 4326 or 3857 ✘".into()));
}
}

Expand Down

0 comments on commit 21b4547

Please sign in to comment.