rich-domain
Version:
This package provide utils file and interfaces to assistant build a complex application with domain driving design
25 lines • 1.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Fail = Fail;
const result_1 = require("./result");
/**
* @description Creates a `Result` instance representing a failure state.
*
* The `Fail` function returns a result indicating that an operation has failed,
* and can optionally include an error message and additional metadata.
*
* @typeParam E - The error type. Defaults to `string`.
* @typeParam M - The metadata type. Defaults to an empty object `{}`.
*
* @param error The error information. If not provided, defaults to a generic error message.
* @param metaData Optional metadata providing additional context about the error.
*
* @returns A `Result` instance with error payload or (`null`) and an error state. The `error` and `metaData`
* types are inferred from the provided arguments.
*/
function Fail(error, metaData) {
const _error = (typeof error !== 'undefined' && error !== null) ? error : 'void error. no message!';
return result_1.default.fail(_error, metaData);
}
exports.default = Fail;
//# sourceMappingURL=fail.js.map