Skip to content

Commit 60d5e45

Browse files
Merge #142
142: Remove implicit conversions for ApiError r=richardwhiuk a=richardwhiuk While well intentioned, these make it too easy for server side business logic to return ApiErrors without due care and attention. As such, it's better for the calling code to explicitly provide the conversion in cases where it's sensible. Signed-off-by: Richard Whitehouse <richard.whitehouse@metaswitch.com> Co-authored-by: Richard Whitehouse <richard.whitehouse@metaswitch.com>
2 parents 5bddefc + 5c61a7c commit 60d5e45

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

CHANGELOG.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8-
### Added
8+
### Breaking Changes
9+
- Remove implicit conversions for ApiError from `&str`, `String` and `serde_json::Error`
10+
- Update `mime_multipart` requirement from 0.5 to 0.6
911

10-
### Changed
12+
### Added
1113

12-
### Removed
1314

1415
## [6.0.0-alpha.1] - 2021-01-21
1516
### Breaking Changes

src/lib.rs

-19
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,3 @@ impl error::Error for ApiError {
7979
"Failed to produce a valid response."
8080
}
8181
}
82-
83-
impl<'a> From<&'a str> for ApiError {
84-
fn from(e: &str) -> Self {
85-
ApiError(e.to_string())
86-
}
87-
}
88-
89-
impl From<String> for ApiError {
90-
fn from(e: String) -> Self {
91-
ApiError(e)
92-
}
93-
}
94-
95-
#[cfg(feature = "serdejson")]
96-
impl From<serde_json::Error> for ApiError {
97-
fn from(e: serde_json::Error) -> Self {
98-
ApiError(format!("Response body did not match the schema: {}", e))
99-
}
100-
}

0 commit comments

Comments
 (0)