diff --git a/apps/orchestrator/src/workflows/post.workflow.ts b/apps/orchestrator/src/workflows/post.workflow.ts index 37ca1864..135cda74 100644 --- a/apps/orchestrator/src/workflows/post.workflow.ts +++ b/apps/orchestrator/src/workflows/post.workflow.ts @@ -194,7 +194,7 @@ export async function postWorkflow({ `Error posting on ${post.integration?.providerIdentifier} for ${post?.integration?.name}`, `An error occurred while posting on ${ post.integration?.providerIdentifier - }${err?.message ? `: ${err?.message}` : ``}`, + }${err?.cause?.message ? `: ${err?.cause?.message}` : ``}`, true, false, 'fail' diff --git a/libraries/nestjs-libraries/src/integrations/social.abstract.ts b/libraries/nestjs-libraries/src/integrations/social.abstract.ts index f225dae3..a3dd40e7 100644 --- a/libraries/nestjs-libraries/src/integrations/social.abstract.ts +++ b/libraries/nestjs-libraries/src/integrations/social.abstract.ts @@ -63,10 +63,18 @@ export abstract class SocialAbstract { value = await func(); } catch (err) { const handle = this.handleErrors(JSON.stringify(err)); - value = { err: true, ...(handle || {}) }; + value = { err: true, value: 'Unknown Error', ...(handle || {}) }; } if (value && value?.err && value?.value) { + if (value.type === 'refresh-token') { + throw new RefreshToken( + '', + JSON.stringify({}), + {} as any, + value.value || '' + ); + } throw new BadBody('', JSON.stringify({}), {} as any, value.value || ''); } diff --git a/libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts b/libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts index d35762f5..96b8858e 100644 --- a/libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts +++ b/libraries/nestjs-libraries/src/integrations/social/youtube.provider.ts @@ -117,6 +117,14 @@ export class YoutubeProvider extends SocialAbstract implements SocialProvider { }; } + if (body.includes('Unauthorized')) { + return { + type: 'refresh-token', + value: + 'Token expired or invalid, please reconnect your YouTube account.', + }; + } + return undefined; }