[][src]Crate try_or_wrap_s

This crate provides a macro similar to the old try! macro, or to the ?, except it wraps the error in something else.

This is useful if you want to use a ? for easily returning say, invalid input errors, but you can't do so because you have an additional Result level for handling internal errors of a different nature.

This macro allows you to do so:

This example is not tested
fn foo(input: Input) -> Result<Result<FinalOutput, InvalidInputError>, DatabaseError> {
    let validated_input: ValidatedInput = try_or_wrap!(validate_input_with_database(input)?, Ok);

fn validate_input_with_database(input: Input) -> Result<Result<ValidatedInput, InvalidInputError>, DatabaseError>;



Helper macro to wrap ? into something else, for Result


Same as try_or_wrap, but for Option