@etsoo/shared
Version:
TypeScript shared utilities and functions
31 lines (30 loc) • 782 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionResult = void 0;
/**
* Action result
*/
class ActionResult {
/**
* Create a result from error
* @returns Action result interface
*/
static create(error) {
// If the error has status / statusCode
const status = "status" in error
? error.status
: "statusCode" in error
? error.statusCode
: undefined;
// Result
const result = {
status: typeof status === "number" ? status : undefined,
ok: false,
type: error.name,
title: error.message
};
// Return
return result;
}
}
exports.ActionResult = ActionResult;