Skip to content

Commit

Permalink
Merge pull request #242 from chmp/feature/errors-for-non-self-describ…
Browse files Browse the repository at this point in the history
…ing-types

Improve errors for non self describing types
  • Loading branch information
chmp authored Sep 30, 2024
2 parents 3de848d + cb946c1 commit a3f3970
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 57 deletions.
113 changes: 61 additions & 52 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ New features

- Add support to auto-detect dates (`2024-09-30`, mapped to `Date32`) and times (`12:00:00`, mapped
to `Time64(Nanosecond))`) in `from_samples`
- Improved error messages for non self describing types (`chrono::*`, `uuid::Uuid`,
`std::net::IpAddr`)

## 0.12.0

Expand Down
12 changes: 9 additions & 3 deletions serde_arrow/src/internal/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,21 @@ impl Error {
Self::Custom(err) => Some(&err.0.annotations),
}
}

pub(crate) fn modify_message<F: FnOnce(&mut String)>(&mut self, func: F) {
let Error::Custom(this) = self;
let inner = this.0.as_mut();
func(&mut inner.message);
}
}

#[derive(PartialEq)]
pub struct CustomError(pub(crate) Box<CustomErrorImpl>);

pub struct CustomErrorImpl {
message: String,
backtrace: Backtrace,
cause: Option<Box<dyn std::error::Error + Send + Sync + 'static>>,
pub(crate) message: String,
pub(crate) backtrace: Backtrace,
pub(crate) cause: Option<Box<dyn std::error::Error + Send + Sync + 'static>>,
pub(crate) annotations: BTreeMap<String, String>,
}

Expand Down
Loading

0 comments on commit a3f3970

Please sign in to comment.