mirror of
https://github.com/facebook/sapling.git
synced 2024-12-29 08:02:24 +03:00
066f461bcf
Summary: Edenapi uses a group of impls like the following as the canonical way to construct ApiError. ``` impl From<Context<ApiErrorKind>> for ApiError { ``` Downstream code would write: ``` use failure::ResultExt; let stream_trees = config .get_or_default("edenapi", "streamtrees") .context(ApiErrorKind::BadConfig("edenapi.streamtrees"))?; ``` This relies on the way that ResultExt::context returns a unique type that is different from failure::Error. This diff introduces a dedicated extension trait to allow the same code in the caller to continue to work even without a failure::Context<T> type, which will be required for dropping our dependency on failure::Fail and failure. ``` pub trait ApiErrorContext<T> { fn context(self, kind: ApiErrorKind) -> ApiResult<T>; } ``` We also introduce a public constructor for ApiError and replace indirect construction that used to look like this: ``` error.context(ApiErrorKind::Curl).into() ``` with this instead: ``` ApiError::new(ApiErrorKind::Curl, error) ``` which is the same number of characters but clearer. The argument order matches [std::io::Error::new](https://doc.rust-lang.org/std/io/struct.Error.html#method.new). Reviewed By: kulshrax Differential Revision: D18574668 fbshipit-source-id: 0a56297bb942a26d75a62ca39fc16abeb4486345 |
||
---|---|---|
.. | ||
bindings | ||
__init__.py | ||
clindex.pyx | ||
linelog.pyx | ||
patchrmdir.pyx | ||
traceprof.pyx |