Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions javascript/__test__/error_handling.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,15 @@ test('error: conn.queryStream() error during iteration throws AdbcError', async
assert.ok(error instanceof AdbcError)
assert.match((error as AdbcError).message, /no such table/i)
})

test('error: missing driver throws NotFound', () => {
assert.throws(
() => new AdbcDatabase({ driver: 'adbc_test_driver_manager_missing_driver_7c8f5482' }),
(e: unknown) => {
assert.ok(e instanceof AdbcError)
assert.strictEqual(e.code, 'NotFound', e.message)
assert.match(e.message, /Driver not found/)
return true
},
)
})
27 changes: 21 additions & 6 deletions rust/driver_manager/src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,15 @@ impl<'a> DriverLibrary<'a> {
}

let driver_name = driver_path.as_os_str().to_string_lossy().into_owned();
let library = DriverLibrary::load_library_from_name(driver_name)?;
Ok(SearchHit::new(driver_path.to_path_buf(), library, None))
// XXX: should we return NotFound like the non-Windows version?
match DriverLibrary::load_library_from_name(driver_name) {
Ok(library) => return Ok(SearchHit::new(driver_path.to_path_buf(), library, None)),
Err(err) => trace.push(err),
}

Err(Error::with_message_and_status(
format!("Driver not found: {}", driver_path.display()),
Status::NotFound,
))
}

#[cfg(not(windows))]
Expand Down Expand Up @@ -1651,7 +1657,7 @@ mod tests {
}

#[test]
fn test_load_from_name_includes_search_trace_in_error_details() {
fn test_load_from_name_missing_driver() {
let err = ManagedDriver::load_from_name(
"adbc_test_driver_manager_missing_driver_7c8f5482",
None,
Expand All @@ -1661,16 +1667,25 @@ mod tests {
)
.unwrap_err();

assert_eq!(err.status, Status::NotFound, "{}", err.message);
assert!(
err.message.contains("Driver not found"),
"Unexpected error message: {}",
err.message
);

let details = err
.details
.expect("Expected load-from-name errors to include details");
let trace = details
.iter()
.find(|(key, _)| key == "adbc.drivermanager.driver_load_trace")
.expect("Expected driver load trace in error details");
// The underlying dynamic library error must be kept in the trace
let trace = String::from_utf8_lossy(&trace.1);
assert!(
!trace.1.is_empty(),
"Expected driver load trace detail to be non-empty"
trace.contains("Error with dynamic library"),
"Expected dynamic library load error in driver load trace, got:\n{trace}"
);
}

Expand Down
Loading