UNPKG

@autorest/common

Version:
49 lines 2.43 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); exports.PluginUserError = exports.OperationAbortedException = exports.OutstandingTaskAlreadyCompletedException = exports.OperationCanceledException = exports.Exception = void 0; class Exception extends Error { constructor(message, exitCode = 1) { super(message.includes("[") ? message : `[Exception] ${message}`); this.exitCode = exitCode; Object.setPrototypeOf(this, Exception.prototype); } } exports.Exception = Exception; class OperationCanceledException extends Exception { constructor(message = "Cancelation Requested", exitCode = 1) { super(`[OperationCanceledException] ${message}`, exitCode); this.exitCode = exitCode; Object.setPrototypeOf(this, OperationCanceledException.prototype); } } exports.OperationCanceledException = OperationCanceledException; class OutstandingTaskAlreadyCompletedException extends Exception { constructor() { super("[OutstandingTaskAlreadyCompletedException] The OutstandingTaskAwaiter is already completed, may not Enter() again.", 1); Object.setPrototypeOf(this, OutstandingTaskAlreadyCompletedException.prototype); } } exports.OutstandingTaskAlreadyCompletedException = OutstandingTaskAlreadyCompletedException; class OperationAbortedException extends Exception { constructor() { super("[OperationAbortedException] Error occurred. Exiting.", 1); Object.setPrototypeOf(this, OperationAbortedException.prototype); } } exports.OperationAbortedException = OperationAbortedException; /** * Represent an error emitted by a plugin where the plugin contains some failure due to the user input. This will make autorest close with a better error message. */ class PluginUserError extends Error { constructor(pluginName) { super(`Plugin '${pluginName}' completed with some error.`); this.pluginName = pluginName; this.code = "PluginUserError"; } } exports.PluginUserError = PluginUserError; //# sourceMappingURL=exceptions.js.map