ProcessingResult<T>: {
    message?: string;
    result?: T;
}

this type allows for a descriptive message to be included in a result from functions that would normally be limited to returning only a single value

ex:

function shouldDoWork(input: Worker): ProcessingResult<boolean> {
try {
const result = input.functionThatMightThrow();
return { result: result };
} catch (e) {
return { result: false, message: Err.short(e) };
}
}

Type Parameters

  • T

Type declaration

  • Optional message?: string

    an optional message explaining why the result is what it is. this is typically set only on error to provide context around the error

  • Optional result?: T

    the result of processing if successful, otherwise undefined

Generated using TypeDoc