@devries-cameron20 / composio-1 / commits / c5b70be46
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Fix pretty print

haxzie committed May 22, 2025 at 18:18 UTC c5b70be460598e03520ff9d5687b5e3a85e541bb
1 file changed +17 -12
packages/core/src/errors/ComposioError.ts
+17 -12
@@ -179,37 +179,42 @@ export class ComposioError extends Error {
179 prettyPrint(includeStack = false): void {
180 const data = this.getErrorData(includeStack);
181
182 - logger.error('\n' + chalk.bgRed.white.bold(' ERROR ') + ' ' + chalk.white.bold(data.message));
182 + let output =
183 + '\n' + chalk.bgRed.white.bold(' ERROR ') + ' ' + chalk.white.bold(data.message) + '\n';
184
185 if (data.code) {
185 - logger.error(chalk.yellow(`Error Code: ${data.code}`));
186 + output += chalk.yellow(`Error Code: ${data.code}`) + '\n';
187 }
188
189 if (data.statusCode !== undefined) {
189 - logger.error(chalk.yellow(`Status: ${data.statusCode}`));
190 + output += chalk.yellow(`Status: ${data.statusCode}`) + '\n';
191 }
192
193 if (data.cause) {
193 - logger.error(chalk.gray('Reason:'));
194 - logger.error(' ' + chalk.white(data.cause));
194 + output += chalk.gray('Reason:') + '\n';
195 + output += ' ' + chalk.white(data.cause) + '\n';
196 }
197
198 if (data.meta) {
198 - logger.error(chalk.gray('Additional Information:'));
199 - logger.error(' ' + chalk.white(JSON.stringify(data.meta, null, 2).replace(/\n/g, '\n ')));
199 + output += chalk.gray('Additional Information:') + '\n';
200 + output +=
201 + ' ' + chalk.white(JSON.stringify(data.meta, null, 2).replace(/\n/g, '\n ')) + '\n';
202 }
203
204 if (data.possibleFixes?.length) {
203 - logger.error('\n' + chalk.cyan.bold('Try the following:'));
204 - logger.error(data.possibleFixes);
205 + output += '\n' + chalk.cyan.bold('Try the following:') + '\n';
206 + const fixes = data.possibleFixes?.map((fix, index) => ` ${index + 1}. ` + chalk.white(fix));
207 + output += fixes?.join('\n') + '\n';
208 }
209
210 if (data.stack?.length) {
208 - logger.error('\n' + chalk.gray('Stack Trace:'));
209 - logger.error(chalk.gray(data.stack.join('\n')));
211 + output += '\n' + chalk.gray('Stack Trace:') + '\n';
212 + output += chalk.gray(data.stack.join('\n')) + '\n';
213 }
214
212 - logger.error(''); // Add a trailing empty line
215 + output += '\n'; // Add a trailing empty line
216 +
217 + logger.error(output);
218 }
219
220 /**