blob: 465dcfa6653e12675c09bc8e2c4b0de149d6229f [file] [log] [blame]
Janis Danisevskis7d77a762020-07-20 13:03:31 -07001// Copyright 2020, The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Keystore error provides convenience methods and types for Keystore error handling.
16//! Clients of Keystore expect one of two error codes, i.e., a Keystore ResponseCode as
17//! defined by the Keystore AIDL interface, or a Keymint ErrorCode as defined by
18//! the Keymint HAL specification.
19//! This crate provides `Error` which can wrap both. It is to be used
20//! internally by Keystore to diagnose error conditions that need to be reported to
21//! the client. To report the error condition to the client the Keystore AIDL
22//! interface defines a wire type `Result` which is distinctly different from Rust's
23//! `enum Result<T,E>`.
24//!
25//! This crate provides the convenience method `map_or_log_err` to convert `anyhow::Error`
26//! into this wire type. In addition to handling the conversion of `Error`
27//! to the `Result` wire type it handles any other error by mapping it to
Janis Danisevskisc5b210b2020-09-11 13:27:37 -070028//! `ResponseCode::SYSTEM_ERROR` and logs any error condition.
Janis Danisevskis7d77a762020-07-20 13:03:31 -070029//!
30//! Keystore functions should use `anyhow::Result` to return error conditions, and
31//! context should be added every time an error is forwarded.
32
33use std::cmp::PartialEq;
Janis Danisevskis7d77a762020-07-20 13:03:31 -070034
Shawn Willden708744a2020-12-11 13:05:27 +000035pub use android_hardware_security_keymint::aidl::android::hardware::security::keymint::ErrorCode::ErrorCode;
Janis Danisevskisc5b210b2020-09-11 13:27:37 -070036pub use android_system_keystore2::aidl::android::system::keystore2::ResponseCode::ResponseCode;
Janis Danisevskis7d77a762020-07-20 13:03:31 -070037
Janis Danisevskisce995432020-07-21 12:22:34 -070038use keystore2_selinux as selinux;
39
Janis Danisevskisc5b210b2020-09-11 13:27:37 -070040use android_system_keystore2::binder::{
Janis Danisevskisba998992020-12-29 16:08:40 -080041 ExceptionCode, Result as BinderResult, Status as BinderStatus, StatusCode,
Janis Danisevskis017d2092020-09-02 10:15:52 -070042};
Janis Danisevskis7d77a762020-07-20 13:03:31 -070043
44/// This is the main Keystore error type. It wraps the Keystore `ResponseCode` generated
45/// from AIDL in the `Rc` variant and Keymint `ErrorCode` in the Km variant.
46#[derive(Debug, thiserror::Error, PartialEq)]
47pub enum Error {
48 /// Wraps a Keystore `ResponseCode` as defined by the Keystore AIDL interface specification.
49 #[error("Error::Rc({0:?})")]
Janis Danisevskise24f3472020-08-12 17:58:49 -070050 Rc(ResponseCode),
Janis Danisevskis7d77a762020-07-20 13:03:31 -070051 /// Wraps a Keymint `ErrorCode` as defined by the Keymint AIDL interface specification.
52 #[error("Error::Km({0:?})")]
Janis Danisevskise24f3472020-08-12 17:58:49 -070053 Km(ErrorCode),
Janis Danisevskis017d2092020-09-02 10:15:52 -070054 /// Wraps a Binder exception code other than a service specific exception.
55 #[error("Binder exception code {0:?}, {1:?}")]
56 Binder(ExceptionCode, i32),
Janis Danisevskisba998992020-12-29 16:08:40 -080057 /// Wraps a Binder status code.
58 #[error("Binder transaction error {0:?}")]
59 BinderTransaction(StatusCode),
Max Biresb2e1d032021-02-08 21:35:05 -080060 /// Wraps a Remote Provisioning ErrorCode as defined by the IRemotelyProvisionedComponent
61 /// AIDL interface spec.
62 #[error("Error::Rp({0:?})")]
63 Rp(ErrorCode),
Janis Danisevskis7d77a762020-07-20 13:03:31 -070064}
65
66impl Error {
Janis Danisevskisc5b210b2020-09-11 13:27:37 -070067 /// Short hand for `Error::Rc(ResponseCode::SYSTEM_ERROR)`
Janis Danisevskis7d77a762020-07-20 13:03:31 -070068 pub fn sys() -> Self {
Janis Danisevskisc5b210b2020-09-11 13:27:37 -070069 Error::Rc(ResponseCode::SYSTEM_ERROR)
Janis Danisevskis7d77a762020-07-20 13:03:31 -070070 }
71
Janis Danisevskisc5b210b2020-09-11 13:27:37 -070072 /// Short hand for `Error::Rc(ResponseCode::PERMISSION_DENIED`
Janis Danisevskis7d77a762020-07-20 13:03:31 -070073 pub fn perm() -> Self {
Janis Danisevskisc5b210b2020-09-11 13:27:37 -070074 Error::Rc(ResponseCode::PERMISSION_DENIED)
Janis Danisevskis7d77a762020-07-20 13:03:31 -070075 }
76}
77
Janis Danisevskis017d2092020-09-02 10:15:52 -070078/// Helper function to map the binder status we get from calls into KeyMint
79/// to a Keystore Error. We don't create an anyhow error here to make
80/// it easier to evaluate KeyMint errors, which we must do in some cases, e.g.,
81/// when diagnosing authentication requirements, update requirements, and running
82/// out of operation slots.
83pub fn map_km_error<T>(r: BinderResult<T>) -> Result<T, Error> {
84 r.map_err(|s| {
85 match s.exception_code() {
86 ExceptionCode::SERVICE_SPECIFIC => {
87 let se = s.service_specific_error();
88 if se < 0 {
89 // Negative service specific errors are KM error codes.
Janis Danisevskisc5b210b2020-09-11 13:27:37 -070090 Error::Km(ErrorCode(s.service_specific_error()))
Janis Danisevskis017d2092020-09-02 10:15:52 -070091 } else {
92 // Non negative error codes cannot be KM error codes.
93 // So we create an `Error::Binder` variant to preserve
94 // the service specific error code for logging.
95 // `map_or_log_err` will map this on a system error,
96 // but not before logging the details to logcat.
97 Error::Binder(ExceptionCode::SERVICE_SPECIFIC, se)
98 }
99 }
100 // We create `Error::Binder` to preserve the exception code
101 // for logging.
102 // `map_or_log_err` will map this on a system error.
103 e_code => Error::Binder(e_code, 0),
104 }
105 })
106}
107
Max Biresb2e1d032021-02-08 21:35:05 -0800108/// Helper function to map the binder status we get from calls into a RemotelyProvisionedComponent
109/// to a Keystore Error. We don't create an anyhow error here to make
110/// it easier to evaluate service specific errors.
111pub fn map_rem_prov_error<T>(r: BinderResult<T>) -> Result<T, Error> {
112 r.map_err(|s| match s.exception_code() {
113 ExceptionCode::SERVICE_SPECIFIC => Error::Rp(ErrorCode(s.service_specific_error())),
114 e_code => Error::Binder(e_code, 0),
115 })
116}
117
Janis Danisevskisba998992020-12-29 16:08:40 -0800118/// This function is similar to map_km_error only that we don't expect
119/// any KeyMint error codes, we simply preserve the exception code and optional
120/// service specific exception.
121pub fn map_binder_status<T>(r: BinderResult<T>) -> Result<T, Error> {
122 r.map_err(|s| match s.exception_code() {
123 ExceptionCode::SERVICE_SPECIFIC => {
124 let se = s.service_specific_error();
125 Error::Binder(ExceptionCode::SERVICE_SPECIFIC, se)
126 }
127 ExceptionCode::TRANSACTION_FAILED => {
128 let e = s.transaction_error();
129 Error::BinderTransaction(e)
130 }
131 e_code => Error::Binder(e_code, 0),
132 })
133}
134
135/// This function maps a status code onto a Keystore Error.
136pub fn map_binder_status_code<T>(r: Result<T, StatusCode>) -> Result<T, Error> {
137 r.map_err(Error::BinderTransaction)
138}
139
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700140/// This function should be used by Keystore service calls to translate error conditions
Janis Danisevskis8ea5f552020-11-20 11:22:59 -0800141/// into service specific exceptions.
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700142///
Janis Danisevskis8ea5f552020-11-20 11:22:59 -0800143/// All error conditions get logged by this function.
144///
145/// All `Error::Rc(x)` and `Error::Km(x)` variants get mapped onto a service specific error
146/// code of x. This is possible because KeyMint `ErrorCode` errors are always negative and
147/// `ResponseCode` codes are always positive.
148/// `selinux::Error::PermissionDenied` is mapped on `ResponseCode::PERMISSION_DENIED`.
149///
150/// All non `Error` error conditions and the Error::Binder variant get mapped onto
151/// ResponseCode::SYSTEM_ERROR`.
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700152///
153/// `handle_ok` will be called if `result` is `Ok(value)` where `value` will be passed
Janis Danisevskis8ea5f552020-11-20 11:22:59 -0800154/// as argument to `handle_ok`. `handle_ok` must generate a `BinderResult<T>`, but it
155/// typically returns Ok(value).
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700156///
157/// # Examples
158///
159/// ```
Janis Danisevskis8ea5f552020-11-20 11:22:59 -0800160/// fn loadKey() -> anyhow::Result<Vec<u8>> {
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700161/// if (good_but_auth_required) {
Janis Danisevskis8ea5f552020-11-20 11:22:59 -0800162/// Ok(vec!['k', 'e', 'y'])
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700163/// } else {
Janis Danisevskis8ea5f552020-11-20 11:22:59 -0800164/// Err(anyhow!(Error::Rc(ResponseCode::KEY_NOT_FOUND)))
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700165/// }
166/// }
167///
Janis Danisevskis8ea5f552020-11-20 11:22:59 -0800168/// map_or_log_err(loadKey(), Ok)
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700169/// ```
Janis Danisevskise24f3472020-08-12 17:58:49 -0700170pub fn map_or_log_err<T, U, F>(result: anyhow::Result<U>, handle_ok: F) -> BinderResult<T>
171where
172 F: FnOnce(U) -> BinderResult<T>,
173{
Janis Danisevskis778245c2021-03-04 15:40:23 -0800174 map_err_with(
175 result,
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700176 |e| {
177 log::error!("{:?}", e);
Janis Danisevskis778245c2021-03-04 15:40:23 -0800178 e
179 },
180 handle_ok,
181 )
182}
183
184/// This function behaves similar to map_or_log_error, but it does not log the errors, instead
185/// it calls map_err on the error before mapping it to a binder result allowing callers to
186/// log or transform the error before mapping it.
187pub fn map_err_with<T, U, F1, F2>(
188 result: anyhow::Result<U>,
189 map_err: F1,
190 handle_ok: F2,
191) -> BinderResult<T>
192where
193 F1: FnOnce(anyhow::Error) -> anyhow::Error,
194 F2: FnOnce(U) -> BinderResult<T>,
195{
196 result.map_or_else(
197 |e| {
198 let e = map_err(e);
Hasini Gunasingheb7142972021-02-20 03:11:27 +0000199 let rc = get_error_code(&e);
Janis Danisevskise24f3472020-08-12 17:58:49 -0700200 Err(BinderStatus::new_service_specific_error(rc, None))
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700201 },
202 handle_ok,
203 )
204}
205
Hasini Gunasingheb7142972021-02-20 03:11:27 +0000206/// Returns the error code given a reference to the error
207pub fn get_error_code(e: &anyhow::Error) -> i32 {
208 let root_cause = e.root_cause();
209 match root_cause.downcast_ref::<Error>() {
210 Some(Error::Rc(rcode)) => rcode.0,
211 Some(Error::Km(ec)) => ec.0,
212 Some(Error::Rp(_)) => ResponseCode::SYSTEM_ERROR.0,
213 // If an Error::Binder reaches this stage we report a system error.
214 // The exception code and possible service specific error will be
215 // printed in the error log above.
216 Some(Error::Binder(_, _)) | Some(Error::BinderTransaction(_)) => {
217 ResponseCode::SYSTEM_ERROR.0
218 }
219 None => match root_cause.downcast_ref::<selinux::Error>() {
220 Some(selinux::Error::PermissionDenied) => ResponseCode::PERMISSION_DENIED.0,
221 _ => ResponseCode::SYSTEM_ERROR.0,
222 },
223 }
224}
225
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700226#[cfg(test)]
Hasini Gunasingheaf993662020-07-24 18:40:20 +0000227pub mod tests {
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700228
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700229 use super::*;
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700230 use android_system_keystore2::binder::{
Janis Danisevskis017d2092020-09-02 10:15:52 -0700231 ExceptionCode, Result as BinderResult, Status as BinderStatus,
232 };
Janis Danisevskise24f3472020-08-12 17:58:49 -0700233 use anyhow::{anyhow, Context};
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700234
Janis Danisevskise24f3472020-08-12 17:58:49 -0700235 fn nested_nested_rc(rc: ResponseCode) -> anyhow::Result<()> {
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700236 Err(anyhow!(Error::Rc(rc))).context("nested nested rc")
237 }
238
Janis Danisevskise24f3472020-08-12 17:58:49 -0700239 fn nested_rc(rc: ResponseCode) -> anyhow::Result<()> {
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700240 nested_nested_rc(rc).context("nested rc")
241 }
242
243 fn nested_nested_ec(ec: ErrorCode) -> anyhow::Result<()> {
244 Err(anyhow!(Error::Km(ec))).context("nested nested ec")
245 }
246
247 fn nested_ec(ec: ErrorCode) -> anyhow::Result<()> {
248 nested_nested_ec(ec).context("nested ec")
249 }
250
Janis Danisevskise24f3472020-08-12 17:58:49 -0700251 fn nested_nested_ok(rc: ResponseCode) -> anyhow::Result<ResponseCode> {
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700252 Ok(rc)
253 }
254
Janis Danisevskise24f3472020-08-12 17:58:49 -0700255 fn nested_ok(rc: ResponseCode) -> anyhow::Result<ResponseCode> {
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700256 nested_nested_ok(rc).context("nested ok")
257 }
258
Janis Danisevskisce995432020-07-21 12:22:34 -0700259 fn nested_nested_selinux_perm() -> anyhow::Result<()> {
260 Err(anyhow!(selinux::Error::perm())).context("nested nexted selinux permission denied")
261 }
262
263 fn nested_selinux_perm() -> anyhow::Result<()> {
264 nested_nested_selinux_perm().context("nested selinux permission denied")
265 }
266
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700267 #[derive(Debug, thiserror::Error)]
268 enum TestError {
269 #[error("TestError::Fail")]
270 Fail = 0,
271 }
272
273 fn nested_nested_other_error() -> anyhow::Result<()> {
274 Err(anyhow!(TestError::Fail)).context("nested nested other error")
275 }
276
277 fn nested_other_error() -> anyhow::Result<()> {
278 nested_nested_other_error().context("nested other error")
279 }
280
Janis Danisevskis017d2092020-09-02 10:15:52 -0700281 fn binder_sse_error(sse: i32) -> BinderResult<()> {
282 Err(BinderStatus::new_service_specific_error(sse, None))
283 }
284
285 fn binder_exception(ex: ExceptionCode) -> BinderResult<()> {
286 Err(BinderStatus::new_exception(ex, None))
287 }
288
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700289 #[test]
290 fn keystore_error_test() -> anyhow::Result<(), String> {
291 android_logger::init_once(
292 android_logger::Config::default()
293 .with_tag("keystore_error_tests")
294 .with_min_level(log::Level::Debug),
295 );
Janis Danisevskise24f3472020-08-12 17:58:49 -0700296 // All Error::Rc(x) get mapped on a service specific error
297 // code of x.
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700298 for rc in ResponseCode::LOCKED.0..ResponseCode::BACKEND_BUSY.0 {
Janis Danisevskise24f3472020-08-12 17:58:49 -0700299 assert_eq!(
300 Result::<(), i32>::Err(rc),
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700301 map_or_log_err(nested_rc(ResponseCode(rc)), |_| Err(BinderStatus::ok()))
Janis Danisevskise24f3472020-08-12 17:58:49 -0700302 .map_err(|s| s.service_specific_error())
303 );
304 }
305
Janis Danisevskis017d2092020-09-02 10:15:52 -0700306 // All Keystore Error::Km(x) get mapped on a service
Janis Danisevskise24f3472020-08-12 17:58:49 -0700307 // specific error of x.
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700308 for ec in ErrorCode::UNKNOWN_ERROR.0..ErrorCode::ROOT_OF_TRUST_ALREADY_SET.0 {
Janis Danisevskise24f3472020-08-12 17:58:49 -0700309 assert_eq!(
310 Result::<(), i32>::Err(ec),
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700311 map_or_log_err(nested_ec(ErrorCode(ec)), |_| Err(BinderStatus::ok()))
Janis Danisevskise24f3472020-08-12 17:58:49 -0700312 .map_err(|s| s.service_specific_error())
313 );
314 }
315
Janis Danisevskis017d2092020-09-02 10:15:52 -0700316 // All Keymint errors x received through a Binder Result get mapped on
317 // a service specific error of x.
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700318 for ec in ErrorCode::UNKNOWN_ERROR.0..ErrorCode::ROOT_OF_TRUST_ALREADY_SET.0 {
Janis Danisevskis017d2092020-09-02 10:15:52 -0700319 assert_eq!(
320 Result::<(), i32>::Err(ec),
321 map_or_log_err(
322 map_km_error(binder_sse_error(ec))
323 .with_context(|| format!("Km error code: {}.", ec)),
324 |_| Err(BinderStatus::ok())
325 )
326 .map_err(|s| s.service_specific_error())
327 );
328 }
329
330 // map_km_error creates an Error::Binder variant storing
331 // ExceptionCode::SERVICE_SPECIFIC and the given
332 // service specific error.
333 let sse = map_km_error(binder_sse_error(1));
334 assert_eq!(Err(Error::Binder(ExceptionCode::SERVICE_SPECIFIC, 1)), sse);
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700335 // map_or_log_err then maps it on a service specific error of ResponseCode::SYSTEM_ERROR.
Janis Danisevskis017d2092020-09-02 10:15:52 -0700336 assert_eq!(
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700337 Result::<(), ResponseCode>::Err(ResponseCode::SYSTEM_ERROR),
Janis Danisevskis017d2092020-09-02 10:15:52 -0700338 map_or_log_err(sse.context("Non negative service specific error."), |_| Err(
339 BinderStatus::ok()
340 ))
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700341 .map_err(|s| ResponseCode(s.service_specific_error()))
Janis Danisevskis017d2092020-09-02 10:15:52 -0700342 );
343
344 // map_km_error creates a Error::Binder variant storing the given exception code.
345 let binder_exception = map_km_error(binder_exception(ExceptionCode::TRANSACTION_FAILED));
346 assert_eq!(Err(Error::Binder(ExceptionCode::TRANSACTION_FAILED, 0)), binder_exception);
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700347 // map_or_log_err then maps it on a service specific error of ResponseCode::SYSTEM_ERROR.
Janis Danisevskis017d2092020-09-02 10:15:52 -0700348 assert_eq!(
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700349 Result::<(), ResponseCode>::Err(ResponseCode::SYSTEM_ERROR),
Janis Danisevskis017d2092020-09-02 10:15:52 -0700350 map_or_log_err(binder_exception.context("Binder Exception."), |_| Err(
351 BinderStatus::ok()
352 ))
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700353 .map_err(|s| ResponseCode(s.service_specific_error()))
Janis Danisevskis017d2092020-09-02 10:15:52 -0700354 );
355
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700356 // selinux::Error::Perm() needs to be mapped to ResponseCode::PERMISSION_DENIED
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700357 assert_eq!(
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700358 Result::<(), ResponseCode>::Err(ResponseCode::PERMISSION_DENIED),
Janis Danisevskise24f3472020-08-12 17:58:49 -0700359 map_or_log_err(nested_selinux_perm(), |_| Err(BinderStatus::ok()))
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700360 .map_err(|s| ResponseCode(s.service_specific_error()))
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700361 );
362
Janis Danisevskise24f3472020-08-12 17:58:49 -0700363 // All other errors get mapped on System Error.
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700364 assert_eq!(
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700365 Result::<(), ResponseCode>::Err(ResponseCode::SYSTEM_ERROR),
Janis Danisevskise24f3472020-08-12 17:58:49 -0700366 map_or_log_err(nested_other_error(), |_| Err(BinderStatus::ok()))
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700367 .map_err(|s| ResponseCode(s.service_specific_error()))
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700368 );
369
370 // Result::Ok variants get passed to the ok handler.
Janis Danisevskisc5b210b2020-09-11 13:27:37 -0700371 assert_eq!(Ok(ResponseCode::LOCKED), map_or_log_err(nested_ok(ResponseCode::LOCKED), Ok));
372 assert_eq!(
373 Ok(ResponseCode::SYSTEM_ERROR),
374 map_or_log_err(nested_ok(ResponseCode::SYSTEM_ERROR), Ok)
375 );
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700376
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700377 Ok(())
378 }
Hasini Gunasingheaf993662020-07-24 18:40:20 +0000379
380 //Helper function to test whether error cases are handled as expected.
Janis Danisevskise24f3472020-08-12 17:58:49 -0700381 pub fn check_result_contains_error_string<T>(
382 result: anyhow::Result<T>,
383 expected_error_string: &str,
384 ) {
Hasini Gunasingheaf993662020-07-24 18:40:20 +0000385 let error_str = format!(
386 "{:#?}",
387 result.err().unwrap_or_else(|| panic!("Expected the error: {}", expected_error_string))
388 );
389 assert!(
390 error_str.contains(expected_error_string),
391 "The string \"{}\" should contain \"{}\"",
392 error_str,
393 expected_error_string
394 );
395 }
Janis Danisevskis7d77a762020-07-20 13:03:31 -0700396} // mod tests