UNPKG

@contract-case/case-core

Version:

Core functionality for the ContractCase contract testing suite

58 lines 2.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.verificationError = exports.triggerError = exports.configurationError = void 0; const case_plugin_base_1 = require("@contract-case/case-plugin-base"); const renderUserFacingStacktrace = (error) => { if (error != null && typeof error === 'object' && 'userFacingStackTrace' in error) { return `\n\n${error.userFacingStackTrace}`; } return ''; }; /** * This represents an error during execution of an example due to user configuration. * * @param error - The error thrown * @param context - the context that the error was in * @returns ExecutionError */ const configurationError = (error, context) => ({ type: case_plugin_base_1.ERROR_TYPE_CONFIGURATION, message: error.message, code: 'ConfigurationError', location: context['_case:currentRun:context:location'], }); exports.configurationError = configurationError; /** * This represents an error thrown by user code during execution of an example * (eg, when a user's trigger is called) * @param error - The error thrown * @param context - the context that the error was in * @returns ExecutionError */ const triggerError = (error, context) => ({ type: case_plugin_base_1.ERROR_TYPE_TRIGGER, message: `${error.message}${renderUserFacingStacktrace(error)}`, code: 'TriggerFunctionError', location: context['_case:currentRun:context:location'], userFacingStackTrace: error.userFacingStackTrace, }); exports.triggerError = triggerError; /** * This represents an error thrown during verification using the provided * verification function * * @param error - The VerifyTriggerReturnObjectError from the verification * @param context - the context that the error was in * @returns VerificationError */ const verificationError = (error, context) => ({ type: case_plugin_base_1.ERROR_TYPE_TEST_RESPONSE, message: `${error.message}${renderUserFacingStacktrace(error)}`, code: error.name, error, location: context['_case:currentRun:context:location'], }); exports.verificationError = verificationError; //# sourceMappingURL=MatchingError.js.map