From 03cf7b4f5c4b91aeec941a478e08a38d9c9542e4 Mon Sep 17 00:00:00 2001 From: Steven Thompson <44806974+thompsonsj@users.noreply.github.com> Date: Tue, 22 Oct 2024 12:24:44 +0100 Subject: [PATCH] fix(api): more informative console log errors from try catch (#206) --- plugin/src/lib/api/helpers.ts | 13 +++++ .../api/payload-crowdin-sync/translations.ts | 54 +++++++++++++++++-- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/plugin/src/lib/api/helpers.ts b/plugin/src/lib/api/helpers.ts index d215cef..31de4fa 100644 --- a/plugin/src/lib/api/helpers.ts +++ b/plugin/src/lib/api/helpers.ts @@ -203,6 +203,19 @@ export async function updatePayloadTranslation({ ...translations }; } catch (error) { + console.log( + 'updatePayloadTranslation', + { + articleDirectoryId, + pluginOptions, + payload, + draft, + dryRun, + excludeLocales, + }, + 'error', + error + ) return { status: 400, error, diff --git a/plugin/src/lib/api/payload-crowdin-sync/translations.ts b/plugin/src/lib/api/payload-crowdin-sync/translations.ts index 7b6aad5..4101a62 100644 --- a/plugin/src/lib/api/payload-crowdin-sync/translations.ts +++ b/plugin/src/lib/api/payload-crowdin-sync/translations.ts @@ -160,7 +160,19 @@ export class payloadCrowdinSyncTranslationsApi { }, }); } catch (error) { - console.log(error); + console.log( + 'updateTranslation', + { + documentId, + collection, + dryRun, + global, + draft, + excludeLocales, + }, + 'error', + error + ); } } else { try { @@ -172,7 +184,19 @@ export class payloadCrowdinSyncTranslationsApi { data: report[locale].latestTranslations, }); } catch (error) { - console.log(error); + console.log( + 'updateTranslation', + { + documentId, + collection, + dryRun, + global, + draft, + excludeLocales, + }, + 'error', + error + ); } } } @@ -250,7 +274,17 @@ export class payloadCrowdinSyncTranslationsApi { }); return docTranslations; } catch (error) { - console.log(error); + console.log( + 'getCurrentDocumentTranslation', + { + doc, + collection, + locale, + global, + }, + 'error', + error + ); throw new Error(`${error}`); } } @@ -420,7 +454,19 @@ export class payloadCrowdinSyncTranslationsApi { return JSON.parse(data); } } catch (error) { - console.log(error); + console.log( + 'getTranslation', + { + documentId, + fieldName, + locale, + collection, + parentCrowdinArticleDirectoryId, + fields + }, + 'error', + error + ); } }