From 81a091e9e1c099efb47e46629ff1f6eb9990a1f7 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Tue, 7 Sep 2021 08:41:35 +0200 Subject: [PATCH] chore: improves logging --- src/routes/route-utils.ts | 4 ++-- src/source/GitHubStream.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/route-utils.ts b/src/routes/route-utils.ts index a72afaa..5b28646 100644 --- a/src/routes/route-utils.ts +++ b/src/routes/route-utils.ts @@ -39,7 +39,7 @@ export async function getRepo( function printError(error: any) { if (error instanceof AnonymousError) { - let detail = error.value?.toString(); + let detail = error.value ? JSON.stringify(error.value) : null; if (error.value instanceof Repository) { detail = error.value.repoId; } else if (error.value instanceof AnonymizedFile) { @@ -54,7 +54,7 @@ function printError(error: any) { console.error( "[ERROR]", error.message, - `'${detail}'`, + detail ? `'${detail}'` : null, error.stack.split("\n")[1].trim() ); } else if (error instanceof Error) { diff --git a/src/source/GitHubStream.ts b/src/source/GitHubStream.ts index 7550103..a5b84ca 100644 --- a/src/source/GitHubStream.ts +++ b/src/source/GitHubStream.ts @@ -59,7 +59,7 @@ export default class GitHubStream extends GitHubBase implements SourceBase { } console.error(error); } - throw new AnonymousError("file_not_accessible"); + throw new AnonymousError("file_not_accessible", file); } async getFiles() {