UNPKG

test-openapi

Version:
49 lines (34 loc) 1.17 kB
"use strict";require("core-js/modules/es.array.iterator");Object.defineProperty(exports,"__esModule",{value:true});exports.addSerializeFail=void 0;var _underscore=require("underscore.string"); var _path=require("../utils/path.js"); var _convert=require("../errors/convert.js"); var _error=require("../errors/error.js"); const addSerializeFail=function({task,error,plugins}){ if(error===undefined){ return task; } const errorA=getSerializeFail({error,plugins}); const errorB=(0,_convert.convertPlainObject)(errorA); return{...task,error:errorB}; };exports.addSerializeFail=addSerializeFail; const getSerializeFail=function({ error:{message,value,path}, plugins}) { const messageA=(0,_underscore.capitalize)(message); const valueA=String(value); const property=(0,_path.getPath)(["task",...path]); const moduleProp=guessModule({path,plugins}); const error=new _error.BugError(messageA,{ value:valueA, property, ...moduleProp}); return error; }; const guessModule=function({path:[name],plugins}){ const plugin=plugins.find(({name:nameA})=>nameA===name); if(plugin===undefined){ return; } return{module:`plugin-${name}`}; }; //# sourceMappingURL=fail.js.map