Skip to content

Commit

Permalink
guard does not fit handlebar error, revert to show informative error …
Browse files Browse the repository at this point in the history
…message (#5529) NV-3772

* fix: guard does not fit error

* feat: remove unused import
  • Loading branch information
ainouzgali authored May 8, 2024
1 parent 8c2c809 commit cdfd0d3
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import * as Handlebars from 'handlebars';
import { format } from 'date-fns';
import { checkIsResponseError, HandlebarHelpersEnum } from '@novu/shared';
import { HandlebarHelpersEnum } from '@novu/shared';

import { CompileTemplateCommand } from './compile-template.command';
import * as i18next from 'i18next';
Expand Down Expand Up @@ -214,12 +214,10 @@ export class CompileTemplate {
const template = Handlebars.compile(templateContent);

result = template(command.data, {});
} catch (e: unknown) {
let errorMessage = `Message content could not be generated`;
if (checkIsResponseError(e)) {
errorMessage = e.message;
}
throw new ApiException(errorMessage);
} catch (e: any) {
throw new ApiException(
e?.message || `Message content could not be generated`
);
}

return result.replace(/'/g, "'");
Expand Down

0 comments on commit cdfd0d3

Please sign in to comment.