UNPKG

@apistudio/apim-cli

Version:

CLI for API Management Products

33 lines (26 loc) 845 B
/** * Copyright Super iPaaS Integration LLC, an IBM Company 2024 */ import { ErrorResponse } from '../models/interface.js'; import { LogWrapper } from '../service/log-wrapper.js'; export const errorsArray: ErrorResponse[] = []; export const addErrorToResponse = (errorCode: string, field: string, description: string) => { errorsArray.push({ code: errorCode, field: field, description: description }); LogWrapper.logDebug('0202', errorCode, field, description); }; export const constructErrorResponse = () => { LogWrapper.logDebug('0003', 'Constructing error response.'); const tempErrorsArray = [...errorsArray]; errorsArray.length = 0; LogWrapper.logDebug('0203', `${tempErrorsArray.length}`); return { respCode: 400, message: 'Invalid Assets or Reference in the Zip', Endpoints: [], errors: tempErrorsArray }; };