UNPKG

@microsoft/teamsfx-api

Version:

teamsfx framework api

158 lines 4.52 kB
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. Object.defineProperty(exports, "__esModule", { value: true }); exports.SystemError = exports.UserError = void 0; /** * Users can recover by themselves, e.g., users input invalid app names. */ class UserError extends Error { /** * Custom error details . */ innerError; /** * Source name of error. (plugin name, eg: tab-scaffold-plugin) */ source; /** * Time of error. */ timestamp; /** * A wiki website that shows mapping relationship between error names, descriptions, and fix solutions. */ helpLink; /** * data that only be reported to github issue manually by user and will not be reported as telemetry data */ userData; /** * message show in the UI */ displayMessage; categories; telemetryProperties; /** * whether to skip process (such as mask secret tokens) in telemetry collection */ skipProcessInTelemetry; /** * recommended operation for user to fix the error * e.g. "debug-in-test-tool" */ recommendedOperation; constructor(param1, param2, param3, param4) { let option; if (typeof param1 === "string") { option = { source: param1, name: param2, message: param3, displayMessage: param4, }; } else { option = param1; } // message const message = option.message || option.error?.message; super(message); //name this.name = option.name || new.target.name; //source this.source = option.source || "unknown"; //stack Error.captureStackTrace(this, new.target); //prototype Object.setPrototypeOf(this, new.target.prototype); //innerError this.innerError = option.error; //other fields this.helpLink = option.helpLink; this.userData = option.userData; this.displayMessage = option.displayMessage; this.timestamp = new Date(); this.categories = option.categories; this.skipProcessInTelemetry = option.skipProcessInTelemetry; this.telemetryProperties = option.telemetryProperties; } } exports.UserError = UserError; /** * Users cannot handle it by themselves. */ class SystemError extends Error { /** * Custom error details. */ innerError; /** * Source name of error. (plugin name, eg: tab-scaffold-plugin) */ source; /** * Time of error. */ timestamp; /** * A github issue page where users can submit a new issue. */ issueLink; /** * data that only be reported to github issue manually by user and will not be reported as telemetry data */ userData; /** * message show in the UI */ displayMessage; categories; telemetryProperties; /** * whether to skip process (such as mask secret tokens) in telemetry collection */ skipProcessInTelemetry; /** * recommended operation for user to fix the error * e.g. "debug-in-test-tool" */ recommendedOperation; constructor(param1, param2, param3, param4) { let option; if (typeof param1 === "string") { option = { source: param1, name: param2, message: param3, displayMessage: param4, }; } else { option = param1; } // message const message = option.message || option.error?.message; super(message); //name this.name = option.name || new.target.name; //source this.source = option.source || "unknown"; //stack Error.captureStackTrace(this, new.target); //prototype Object.setPrototypeOf(this, new.target.prototype); //innerError this.innerError = option.error; //other fields this.issueLink = option.issueLink; this.userData = option.userData; this.displayMessage = option.displayMessage; this.timestamp = new Date(); this.categories = option.categories; this.skipProcessInTelemetry = option.skipProcessInTelemetry; this.telemetryProperties = option.telemetryProperties; } } exports.SystemError = SystemError; //# sourceMappingURL=error.js.map