Use io::Error::other

pull/779/head
Yuri Astrakhan 11 months ago
parent f5de5d3e98
commit 3dcae19e27
  1. 4
      .github/workflows/tests.yml
  2. 2
      Cargo.toml
  3. 2
      lib/oxigraph/src/sparql/error.rs
  4. 26
      lib/oxigraph/src/sparql/http/simple.rs
  5. 9
      lib/oxigraph/src/storage/backend/rocksdb.rs
  6. 2
      lib/oxigraph/src/storage/error.rs
  7. 17
      lib/oxigraph/src/storage/mod.rs
  8. 2
      lib/oxrdfxml/src/serializer.rs

@ -175,7 +175,7 @@ jobs:
submodules: true submodules: true
- uses: ./.github/actions/setup-rust - uses: ./.github/actions/setup-rust
with: with:
version: 1.70.0 version: 1.74.0
- run: rustup toolchain install nightly - run: rustup toolchain install nightly
- run: rm Cargo.lock && cargo +nightly update -Z direct-minimal-versions - run: rm Cargo.lock && cargo +nightly update -Z direct-minimal-versions
- run: cargo test - run: cargo test
@ -312,7 +312,7 @@ jobs:
submodules: true submodules: true
- uses: ./.github/actions/setup-rust - uses: ./.github/actions/setup-rust
with: with:
version: 1.70.0 version: 1.74.0
- run: rustup toolchain install nightly - run: rustup toolchain install nightly
- uses: actions/setup-python@v4 - uses: actions/setup-python@v4
with: with:

@ -23,7 +23,7 @@ version = "0.4.0-alpha.3-dev"
authors = ["Tpt <thomas@pellissier-tanon.fr>"] authors = ["Tpt <thomas@pellissier-tanon.fr>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.70" rust-version = "1.74"
[workspace.dependencies] [workspace.dependencies]
anyhow = "1.0.72" anyhow = "1.0.72"

@ -138,7 +138,7 @@ impl From<EvaluationError> for io::Error {
EvaluationError::Storage(error) => error.into(), EvaluationError::Storage(error) => error.into(),
EvaluationError::Service(error) => match error.downcast() { EvaluationError::Service(error) => match error.downcast() {
Ok(error) => *error, Ok(error) => *error,
Err(error) => Self::new(io::ErrorKind::Other, error), Err(error) => Self::other(error),
}, },
EvaluationError::GraphAlreadyExists(_) EvaluationError::GraphAlreadyExists(_)
| EvaluationError::GraphDoesNotExist(_) | EvaluationError::GraphDoesNotExist(_)

@ -26,15 +26,10 @@ impl Client {
let response = self.client.request(request)?; let response = self.client.request(request)?;
let status = response.status(); let status = response.status();
if !status.is_successful() { if !status.is_successful() {
return Err(Error::new( return Err(Error::other(format!(
ErrorKind::Other, "Error {status} returned by {url} with payload:\n{}",
format!( response.into_body().to_string()?
"Error {} returned by {} with payload:\n{}", )));
status,
url,
response.into_body().to_string()?
),
));
} }
let content_type = response let content_type = response
.header(&HeaderName::CONTENT_TYPE) .header(&HeaderName::CONTENT_TYPE)
@ -61,15 +56,10 @@ impl Client {
let response = self.client.request(request)?; let response = self.client.request(request)?;
let status = response.status(); let status = response.status();
if !status.is_successful() { if !status.is_successful() {
return Err(Error::new( return Err(Error::other(format!(
ErrorKind::Other, "Error {status} returned by {url} with payload:\n{}",
format!( response.into_body().to_string()?
"Error {} returned by {} with payload:\n{}", )));
status,
url,
response.into_body().to_string()?
),
));
} }
let content_type = response let content_type = response
.header(&HeaderName::CONTENT_TYPE) .header(&HeaderName::CONTENT_TYPE)

@ -456,14 +456,11 @@ impl Db {
if let Some(available_fd) = available_file_descriptors()? { if let Some(available_fd) = available_file_descriptors()? {
if available_fd < 96 { if available_fd < 96 {
rocksdb_options_destroy(options); rocksdb_options_destroy(options);
return Err(io::Error::new( return Err(io::Error::other(format!(
io::ErrorKind::Other, "Oxigraph needs at least 96 file descriptors, \
format!(
"Oxigraph needs at least 96 file descriptors, \
only {available_fd} allowed. \ only {available_fd} allowed. \
Run e.g. `ulimit -n 512` to allow 512 opened files" Run e.g. `ulimit -n 512` to allow 512 opened files"
), ))
)
.into()); .into());
} }
rocksdb_options_set_max_open_files( rocksdb_options_set_max_open_files(

@ -50,7 +50,7 @@ impl From<StorageError> for io::Error {
match error { match error {
StorageError::Io(error) => error, StorageError::Io(error) => error,
StorageError::Corruption(error) => error.into(), StorageError::Corruption(error) => error.into(),
StorageError::Other(error) => Self::new(io::ErrorKind::Other, error), StorageError::Other(error) => Self::other(error),
} }
} }
} }

@ -1316,7 +1316,7 @@ impl StorageBulkLoader {
) -> Result<(), StorageError> { ) -> Result<(), StorageError> {
let new_counter = *done let new_counter = *done
.lock() .lock()
.map_err(|_| io::Error::new(io::ErrorKind::Other, "Mutex poisoned"))?; .map_err(|_| io::Error::other("Mutex poisoned"))?;
let display_step = DEFAULT_BULK_LOAD_BATCH_SIZE as u64; let display_step = DEFAULT_BULK_LOAD_BATCH_SIZE as u64;
if new_counter / display_step > *done_and_displayed / display_step { if new_counter / display_step > *done_and_displayed / display_step {
for hook in &self.hooks { for hook in &self.hooks {
@ -1355,7 +1355,7 @@ impl<'a> FileBulkLoader<'a> {
self.save()?; self.save()?;
*counter *counter
.lock() .lock()
.map_err(|_| io::Error::new(io::ErrorKind::Other, "Mutex poisoned"))? += .map_err(|_| io::Error::other("Mutex poisoned"))? +=
size.try_into().unwrap_or(u64::MAX); size.try_into().unwrap_or(u64::MAX);
Ok(()) Ok(())
} }
@ -1546,13 +1546,10 @@ impl<'a> FileBulkLoader<'a> {
#[cfg(not(target_family = "wasm"))] #[cfg(not(target_family = "wasm"))]
fn map_thread_result<R>(result: thread::Result<R>) -> io::Result<R> { fn map_thread_result<R>(result: thread::Result<R>) -> io::Result<R> {
result.map_err(|e| { result.map_err(|e| {
io::Error::new( io::Error::other(if let Ok(e) = e.downcast::<&dyn std::fmt::Display>() {
io::ErrorKind::Other, format!("A loader processed crashed with {e}")
if let Ok(e) = e.downcast::<&dyn std::fmt::Display>() { } else {
format!("A loader processed crashed with {e}") "A loader processed crashed with and unknown error".into()
} else { })
"A loader processed crashed with and unknown error".into()
},
)
}) })
} }

@ -421,7 +421,7 @@ fn map_err(error: quick_xml::Error) -> io::Error {
if let quick_xml::Error::Io(error) = error { if let quick_xml::Error::Io(error) = error {
Arc::try_unwrap(error).unwrap_or_else(|error| io::Error::new(error.kind(), error)) Arc::try_unwrap(error).unwrap_or_else(|error| io::Error::new(error.kind(), error))
} else { } else {
io::Error::new(io::ErrorKind::Other, error) io::Error::other(error)
} }
} }

Loading…
Cancel
Save