UNPKG

test-openapi

Version:
66 lines (46 loc) 1.41 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isBugError=exports.handleBugs=void 0;var _error=require("./error.js"); const handleBugs=function({error}){ const bugError=findBugError({error}); if(bugError===undefined){ return error; } const message=getBugMessage({bugError}); return new _error.BugError(message,{module:bugError.module,bug:true}); };exports.handleBugs=handleBugs; const findBugError=function({error,error:{errors=[error]}}){ const errorA=errors.find(getBugError); if(errorA===undefined){ return; } return getBugError(errorA); }; const getBugError=function(error){ if(isBugError(error)){ return error; } const{nested:{error:nestedError}={}}=error; if(nestedError!==undefined){ return getBugError(nestedError); } }; const isBugError=function({name}){ return name!=="TestOpenApiError"; };exports.isBugError=isBugError; const getBugMessage=function({ bugError, bugError:{message,stack=message}}) { const repositoryName=getRepositoryName({bugError}); return`A bug occurred. Please report an issue on the '${repositoryName}' code repository and paste the following lines: ${stack}`; }; const getRepositoryName=function({bugError}){ if(module===undefined){ return DEFAULT_REPOSITORY; } return`${MODULE_REPOSITORY}${bugError.module}`; }; const DEFAULT_REPOSITORY="test-openapi"; const MODULE_REPOSITORY="test-openapi-"; //# sourceMappingURL=bug.js.map