Skip to content

Commit

Permalink
Fix error parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
marcua committed Jan 19, 2025
1 parent 98d3872 commit eb54b4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ pub enum AybError {
CantSetOwnerPermissions { message: String },
DurationParseError { message: String },
NoWriteAccessError { message: String },
QueryError { message: String },
RecordNotFound { id: String, record_type: String },
S3ExecutionError { message: String },
S3ConnectionError { message: String },
SnapshotError { message: String },
SnapshotDoesNotExistError,
RecordNotFound { id: String, record_type: String },
Other { message: String },
}

Expand Down
14 changes: 9 additions & 5 deletions src/hosted_db/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,16 @@ pub async fn potentially_isolated_sqlite_query(
println!("potentially2");
if !result.stderr.is_empty() {
println!("potentially3");
let error: AybError = serde_json::from_str(&result.stderr)?;
println!("potentially4");
return Err(error);
// Before shipping, consider whether to still try to parse and then catch the parsing error.
return Err(AybError::QueryError {
message: format!(
"Error message from sandboxed query runner: {}",
result.stderr
),
});
} else if result.status != 0 {
println!("potentially5");
return Err(AybError::Other {
return Err(AybError::QueryError {
message: format!(
"Error status from sandboxed query runner: {}",
result.status
Expand All @@ -111,7 +115,7 @@ pub async fn potentially_isolated_sqlite_query(
return Ok(query_result);
} else {
println!("potentially8");
return Err(AybError::Other {
return Err(AybError::QueryError {
message: "No results from sandboxed query runner".to_string(),
});
}
Expand Down

0 comments on commit eb54b4b

Please sign in to comment.