Skip to content

Commit

Permalink
Do not wrap exceptions in Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
William Tisäter committed Oct 24, 2023
1 parent 5ca38cf commit 1dfe1be
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rsmime"
version = "0.3.0"
version = "0.3.1"
edition = "2021"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "rsmime"
version = "0.3.0"
version = "0.3.1"
classifiers = [
"License :: OSI Approved :: MIT License",
"Development Status :: 3 - Alpha",
Expand Down
9 changes: 9 additions & 0 deletions rsmime.pyi
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
class ReadCertificateError(Exception):
...

class LoadCertificateError(Exception):
...

class SignError(Exception):
...

def sign(cert_file: str, key_file: str, data_to_sign: bytes) -> str:
...
9 changes: 2 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ pub fn _sign(cert_file: &str, key_file: &str, data_to_sign: &[u8]) -> PyResult<V
#[pyfunction]
fn sign(cert_file: &str, key_file: &str, data_to_sign: Vec<u8>) -> PyResult<String> {
match _sign(cert_file, key_file, &data_to_sign) {
Ok(signed_data) => {
match String::from_utf8(signed_data) {
Ok(signed_string) => Ok(signed_string),
Err(err) => Err(PyException::new_err(err))
}
},
Err(err) => Err(PyException::new_err(err.to_string())),
Ok(signed_data) => Ok(String::from_utf8(signed_data).expect("Failed to convert to string")),
Err(err) => Err(err),
}
}

Expand Down

0 comments on commit 1dfe1be

Please sign in to comment.