Lines Matching refs:TestError

21 struct TestError(u32);  struct
23 impl fmt::Display for TestError { implementation
29 impl core::error::Error for TestError {} implementation
85 let mut error = Error::new(TestError(42)); in new()
86 assert!(error.is::<TestError>()); in new()
87 assert_eq!(error.downcast_ref::<TestError>().unwrap().0, 42); in new()
88 error.downcast_mut::<TestError>().unwrap().0 += 1; in new()
89 assert_eq!(error.downcast_ref::<TestError>().unwrap().0, 43); in new()
148 let error = Error::from(TestError(42)); in from_error()
149 assert!(error.is::<TestError>()); in from_error()
150 assert_eq!(error.downcast_ref::<TestError>().unwrap().0, 42); in from_error()
176 assert!(!e.is::<TestError>()); in is()
180 let e = e.context(TestError(42)); in is()
182 assert!(e.is::<TestError>()); in is()
187 let e = e.context(TestError(36)).context("another str"); in is()
189 assert!(e.is::<TestError>()); in is()
193 let e = Error::from(TestError(36)); in is()
194 assert!(e.is::<TestError>()); in is()
201 assert!(!e.is::<TestError>()); in is()
242 assert_backtrace(Error::new(TestError(42))); in backtrace()
245 assert_backtrace(Error::new(TestError(42)).context("yikes")); in backtrace()
272 let error = TestError(42); in format_err_macro_core_error()
274 assert!(error.is::<TestError>()); in format_err_macro_core_error()
336 bail!(TestError(13)) in bail_macro()
380 ensure!(c, TestError(13)); in ensure_macro()
419 let error = error.downcast::<TestError>().unwrap_err(); in downcast()
424 let error = Error::new(TestError(42)); in downcast()
427 assert_eq!(error.downcast::<TestError>().unwrap().0, 42); in downcast()
432 let error = error.downcast::<TestError>().unwrap_err(); in downcast()
436 let error = Error::new(TestError(42)) in downcast()
443 let error = Error::new(TestError(42)) in downcast()
450 let error = Error::new(TestError(42)) in downcast()
454 assert_eq!(error.downcast::<TestError>().unwrap().0, 42); in downcast()
457 let error = Error::new(TestError(42)).context(TestError(36)); in downcast()
458 assert_eq!(error.downcast::<TestError>().unwrap().0, 36); in downcast()
491 assert!(e.downcast_ref::<TestError>().is_none()); in downcast_ref()
495 let e = e.context(TestError(42)); in downcast_ref()
497 assert_eq!(e.downcast_ref::<TestError>().unwrap().0, 42); in downcast_ref()
503 assert_eq!(e.downcast_ref::<TestError>().unwrap().0, 42); in downcast_ref()
507 let e = Error::from(TestError(36)); in downcast_ref()
508 assert_eq!(e.downcast_ref::<TestError>().unwrap().0, 36); in downcast_ref()
515 assert!(e.downcast_ref::<TestError>().is_none()); in downcast_ref()
523 assert!(e.downcast_mut::<TestError>().is_none()); in downcast_mut()
529 let mut e = e.context(TestError(42)); in downcast_mut()
533 e.downcast_mut::<TestError>().unwrap().0 += 1; in downcast_mut()
534 assert_eq!(e.downcast_ref::<TestError>().unwrap().0, 43); in downcast_mut()
543 let mut e = Error::from(TestError(36)); in downcast_mut()
546 e.downcast_mut::<TestError>().unwrap().0 += 1; in downcast_mut()
547 assert_eq!(e.downcast_ref::<TestError>().unwrap().0, 37); in downcast_mut()
552 assert!(e.downcast_mut::<TestError>().is_none()); in downcast_mut()
570 let result = result.context("uh oh").context(TestError(1337)); in context_on_ok_result()
576 let result: Result<u32> = Err(Error::new(TestError(42))).context("uh oh"); in context_on_err_result()
579 assert!(error.is::<TestError>()); in context_on_err_result()
580 assert_eq!(error.downcast_ref::<TestError>().unwrap().0, 42); in context_on_err_result()
589 let result = option.context("uh oh").context(TestError(1337)); in context_on_some_option()
596 let result = option.context(TestError(42)).context("uh oh"); in context_on_none_option()
599 assert!(error.is::<TestError>()); in context_on_none_option()
600 assert_eq!(error.downcast_ref::<TestError>().unwrap().0, 42); in context_on_none_option()
611 .with_context(|| TestError(36)); in with_context_on_ok_result()
617 let result: Result<u32> = Err(Error::new(TestError(36))); in with_context_on_err_result()
621 assert!(error.is::<TestError>()); in with_context_on_err_result()
631 .with_context(|| TestError(42)); in with_context_on_some_option()
640 .with_context(|| TestError(42)); in with_context_on_none_option()
646 assert!(error.is::<TestError>()); in with_context_on_none_option()
647 assert_eq!(error.downcast_ref::<TestError>().unwrap().0, 42); in with_context_on_none_option()
708 .context(TestError(42)) in fmt_debug_alternate()
796 .context(TestError(42)); in chain()
871 let error = Error::new(ErrorWithSource("leaf".to_string(), Box::new(TestError(42)))) in chain_with_leaf_sources()
919 let e: Error = TestError(1).into(); in anyhow_preserves_downcast()
920 assert!(e.downcast_ref::<TestError>().is_some()); in anyhow_preserves_downcast()
922 assert!(e.downcast_ref::<TestError>().is_some()); in anyhow_preserves_downcast()
925 let e = Error::from(TestError(1)).context("hi"); in anyhow_preserves_downcast()
926 assert!(e.downcast_ref::<TestError>().is_some()); in anyhow_preserves_downcast()
929 assert!(e.downcast_ref::<TestError>().is_some()); in anyhow_preserves_downcast()
938 let e: anyhow::Error = TestError(1).into(); in anyhow_source_downcast()
939 assert!(e.downcast_ref::<TestError>().is_some()); in anyhow_source_downcast()
942 assert!(e.downcast_ref::<TestError>().is_some()); in anyhow_source_downcast()
945 assert!(e.downcast_ref::<TestError>().is_some()); in anyhow_source_downcast()
973 let e: anyhow::Error = TestError(1).into(); in anyhow_wasmtime_anyhow_sandwich_chain()
974 let e = e.context(TestError(2)); in anyhow_wasmtime_anyhow_sandwich_chain()
982 let e = e.context(TestError(3)); in anyhow_wasmtime_anyhow_sandwich_chain()
990 let e = e.context(TestError(4)); in anyhow_wasmtime_anyhow_sandwich_chain()
1008 let e: Error = TestError(1).into(); in wasmtime_anyhow_wasmtime_sandwich_chain()
1009 let e = e.context(TestError(2)); in wasmtime_anyhow_wasmtime_sandwich_chain()
1017 let e = e.context(TestError(3)); in wasmtime_anyhow_wasmtime_sandwich_chain()
1025 let e = e.context(TestError(4)); in wasmtime_anyhow_wasmtime_sandwich_chain()