Skip to content
Closed
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added
### Changed

- Removed custom serde error formatting to avoid float inclusion. ([#42])
- Add support for `str_collect` serialization.

[#42]: https://github.com/CosmWasm/serde-json-wasm/issues/42

## [0.5.0] - 2022-12-06

Expand Down
10 changes: 5 additions & 5 deletions src/de/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ pub enum Error {
/// JSON has a comma after the last value in an array or map.
TrailingComma,

/// Custom error message from serde
Custom(String),
/// Custom error message from serde that should be discarded to avoid floats
Custom,
}

impl error::Error for Error {
Expand All @@ -83,11 +83,11 @@ impl error::Error for Error {
}

impl de::Error for Error {
fn custom<T>(msg: T) -> Self
fn custom<T>(_msg: T) -> Self
where
T: fmt::Display,
{
Error::Custom(msg.to_string())
Error::Custom
}
}

Expand Down Expand Up @@ -132,7 +132,7 @@ impl fmt::Display for Error {
value."
}
Error::TrailingComma => "JSON has a comma after the last value in an array or map.",
Error::Custom(msg) => msg,
Error::Custom => "Custom error from serde was discarded to avoid float inclusion",
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ mod tests {

// wrong number of args
match from_str::<Xy>(r#"[10]"#) {
Err(super::Error::Custom(_)) => {}
Err(super::Error::Custom) => {}
_ => panic!("expect custom error"),
}
assert_eq!(
Expand Down