UNPKG

@neo-one/smart-contract-compiler

Version:

NEO•ONE TypeScript smart contract compiler.

29 lines (27 loc) 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.throwOnDiagnosticErrorOrWarning = void 0; const tslib_1 = require("tslib"); const typescript_1 = tslib_1.__importDefault(require("typescript")); const getDiagnosticMessage_1 = require("./getDiagnosticMessage"); function throwOnDiagnosticErrorOrWarning(diagnostics, ignoreWarnings = false, message = '') { const errors = diagnostics.filter((diagnostic) => diagnostic.category === typescript_1.default.DiagnosticCategory.Error); const warnings = diagnostics.filter((diagnostic) => diagnostic.category === typescript_1.default.DiagnosticCategory.Warning); const errorMessage = errors.length === 0 ? undefined : errors.map((error) => `Compilation error: ${getDiagnosticMessage_1.getDiagnosticMessage(error)}`).join('\n'); const warningMessage = warnings.length === 0 ? undefined : warnings.map((warning) => `Compilation warning: ${getDiagnosticMessage_1.getDiagnosticMessage(warning)}`).join('\n'); if (errorMessage !== undefined) { const error = new Error(`${errorMessage}${warningMessage === undefined ? '' : warningMessage}`); error.message = message; error.stack = errorMessage; throw error; } if (warningMessage !== undefined && !ignoreWarnings) { throw new Error(warningMessage); } } exports.throwOnDiagnosticErrorOrWarning = throwOnDiagnosticErrorOrWarning; //# sourceMappingURL=throwOnDiagnosticErrorOrWarning.js.map