@etsoo/appscript
Version:
Applications shared TypeScript framework
38 lines (37 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionResultError = void 0;
/**
* Action result error
*/
class ActionResultError extends Error {
/**
* Format the result to a meaningful string
* @param result Result
*/
static format(result) {
// Additional data
const addtions = [];
if (result.status != null)
addtions.push(result.status);
if (result.type)
addtions.push(result.type);
if (result.field)
addtions.push(result.field);
const add = addtions.length > 0 ? ` (${addtions.join(", ")})` : "";
return `${result.title || "Error"}${add}`;
}
/**
* Constructor
* @param result Result
*/
constructor(result) {
// Super
super(ActionResultError.format(result));
// Name
this.name = "ActionResultError";
// Hold the result
this.result = result;
}
}
exports.ActionResultError = ActionResultError;