@etsoo/appscript
Version:
Applications shared TypeScript framework
34 lines (33 loc) • 873 B
JavaScript
/**
* Action result error
*/
export 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;
}
}