1 assert(err("foo").expectErr("oops") == "foo");
2 version (D_Exceptions)
3 {
4 assert(collectExceptionMsg!Throwable(Expected!int.init.expectErr("oops")) == "oops: empty");
5 assert(collectExceptionMsg!Throwable(ok(42).expectErr("oops")) == "oops: 42");
6 assert(collectExceptionMsg!Throwable(ok().expectErr("oops")) == "oops: empty"); // void value
7 }
8
9 assert(ok("foo").expect!(a => "bar") == "foo");
10 assert(err!string("foo").expect!(a => "bar") == "bar");
11 assert(err!string("foo").expect!((a) {}) is null);
12
13 assert(ok("foo").expectErr!(a => "bar") == "bar");
14 assert(err!string("foo").expectErr!(a => "bar") == "foo");
15 assert(ok!string("foo").expectErr!((a) {}) is null);
Unwraps a result, yielding the content of an error value. If there is none, or success value, it throws assert(0) with the provided message.