idiomatic error handling #1
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "idiomatic_error_handling"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
New error handling with thiserror
@ -113,4 +141,0 @@
let decrypt_result = os::try_backup_keyfile(&form.keyfile);
if let Err(decryption_error) = decrypt_result {
return HttpResponse::BadRequest()
.body(format!("Could not decrypt root: {decryption_error:?}"));
Did we a test with a corrupted disk to see what error is displayed for the CLI?
@ -36,3 +68,2 @@
fn get_cert_hash() -> [u8; 64] {
fn get_cert_hash() -> Result<[u8; 64], DtrfsError> {
let mut hasher = Sha3_512::new();
let crt = File::open(CRT_FILE).expect("Could not open crt file.");
I see this error message got removed. In case dtrfs fails now, what error will be displayed in the console of the VM?
If someone runs this code to troubleshoot potential issues or to expand functionality, will that person receive an error informing about the missing certificate?
@ -18,0 +42,4 @@
impl ResponseError for DtrfsError {
fn error_response(&self) -> HttpResponse {
match self {
error => HttpResponse::InternalServerError().body(format!("{}", error)),
Is it possible to respect HTTP error codes? Link here: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
Maybe a match on DtrfsError?
@ -100,0 +125,4 @@
req: HttpRequest,
form: web::Form<InstallForm>,
) -> Result<HttpResponse, Error> {
verify(&req)?;// TODO: This is temporary, we need to merget from the other branch
Not sure what is temporary.
@ -4,3 +4,2 @@
use sev::firmware::guest::{AttestationReport, DerivedKey, Firmware, GuestFieldSelect};
fn request_hardware_report(data: [u8; 64]) -> Result<AttestationReport> {
let mut fw = Firmware::open().context("unable to open /dev/sev-guest")?;
I don't see mention of
/dev/sev-guest
anywhere. I believe it is important to mention this file if the firmware fails to open.After going through this code, we figured out dtrfs has particular error requirements, because:
As these requirements were not clear before this branch got started, we will consider this a great exercise.
@ramrem Congratulations on learning how to write idiomatic errors in Rust! We appreciate it! No hard feelings. We will redesign this.
All Love. Closed.
Pull request closed