Skip to content

Commit

Permalink
updated error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
vishvamsinh28 committed Dec 9, 2024
1 parent fca4dcc commit 98f3238
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 7 additions & 4 deletions scripts/tools/combine-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,13 @@ const combineTools = async (automatedTools, manualTools, toolsPath, tagsPath) =>
let toolObject = await createToolObject(tool, "", "", isAsyncAPIrepo)
finalToolsList.push(await getFinalTool(toolObject))
} else {
console.error('Script is not failing, it is just dropping errors for further investigation');
console.error(`Invalid ${tool.title} .asyncapi-tool file.`);
console.error(`Located in manual-tools.json file`);
console.error('Validation errors:', JSON.stringify(validate.errors, null, 2));
console.error({
message: 'Tool validation failed',
tool: tool.title,
source: 'manual-tools.json',
errors: validate.errors,
note: 'Script continues execution, error logged for investigation'
});
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions tests/tools/combine-tools.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ describe('combineTools function', () => {
it('should log validation errors to console.error', async () => {
await combineTools(automatedToolsT4, manualToolsT4, toolsPath, tagsPath);

const errorCalls = console.error.mock.calls;
const { message, tool, source, note } = console.error.mock.calls[0][0];

expect(errorCalls[0][0]).toBe('Script is not failing, it is just dropping errors for further investigation');
expect(errorCalls[1][0]).toBe('Invalid Invalid Tool .asyncapi-tool file.');
expect(errorCalls[2][0]).toBe('Located in manual-tools.json file');
expect(errorCalls[3][0]).toEqual(expect.stringContaining('Validation errors:'));
expect(message).toBe('Tool validation failed');
expect(tool).toBe('Invalid Tool');
expect(source).toBe('manual-tools.json');
expect(note).toBe('Script continues execution, error logged for investigation');

expect(fs.existsSync(toolsPath)).toBe(true);
expect(fs.existsSync(tagsPath)).toBe(true);
Expand Down

0 comments on commit 98f3238

Please sign in to comment.