Skip to content

Commit

Permalink
Remove unused docsPageUrl property from error interface and showCoreE…
Browse files Browse the repository at this point in the history
…rror function
  • Loading branch information
= committed Dec 12, 2023
1 parent dffdc50 commit e47490e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 40 deletions.
6 changes: 6 additions & 0 deletions .changeset/blue-rats-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'jsx-mail': patch
'@jsx-mail/core': patch
---

remove docs url from core error
39 changes: 0 additions & 39 deletions packages/core/src/utils/error.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { readGlobalVariable } from './global';
import WEBSITE_URL from './website-url';

interface IError {
name: string;
message: string;
docsPageUrl: string;
solutions?: string[];
}

Expand All @@ -13,172 +11,140 @@ export const ERRORS: IError[] = [
name: 'unknown',
message:
'This is an unknown error, please open an issue at https://github.com/Theryston/jsx-mail/issues reporting the entire process and its flow until reaching this error',
docsPageUrl: `${WEBSITE_URL}/docs/errors/unknown`,
},
{
name: 'no_template_folder',
message:
'You should create a folder called `templates` in your email application, create a .tsx/.jsx file in the `templates` folder and export some component as default',
docsPageUrl: `${WEBSITE_URL}/docs/errors/no-template-folder`,
},
{
name: 'compile_files',
message:
"I didn't find any file with the extension .tsx/.jsx/.js/.ts in your mail app, please create one and export a component as default",
docsPageUrl: `${WEBSITE_URL}/docs/errors/no-tsx-or-jsx-files`,
},
{
name: 'compilation_error',
message: 'There was an error trying to compile the template',
docsPageUrl: `${WEBSITE_URL}/docs/errors/compilation-error`,
},
{
name: 'export_a_component_as_default',
message:
'You must export by default a function that returns a jsx component',
docsPageUrl: `${WEBSITE_URL}/docs/errors/export-a-component-as-default`,
},
{
name: 'fails_to_run_template_in_prepare',
message:
'The prepare process tried to run your template, but received an error',
docsPageUrl: `${WEBSITE_URL}/docs/errors/fails-to-run-template-in-prepare`,
},
{
name: 'not_supported_tag',
message:
"You used a tag not supported by email clients so it doesn't exist in jsx mail",
docsPageUrl: `${WEBSITE_URL}/docs/errors/not-supported-tag`,
},
{
name: 'not_supported_style',
message:
'You used css which is not supported by some email clients so it is not implemented in JSX Mail',
docsPageUrl: `${WEBSITE_URL}/docs/errors/not-supported-style`,
},
{
name: 'not_supported_style_value',
message:
'The value you used in your css is not supported by some email clients',
docsPageUrl: `${WEBSITE_URL}/docs/errors/not-supported-style-value`,
},
{
name: 'promise_not_allowed',
message:
'No component can return a promise, please do all the asynchronous things you have to do directly in "onRender"',
docsPageUrl: `${WEBSITE_URL}/docs/errors/promise-not-allowed`,
},
{
name: 'not_supported_props',
message: 'You used props that are not supported by this tag',
docsPageUrl: `${WEBSITE_URL}/docs/errors/not-supported-props`,
},
{
name: 'no_template_name',
message: 'You must enter a template name',
docsPageUrl: `${WEBSITE_URL}/docs/errors/no-template-name`,
},
{
name: 'on_render_error',
message: 'Error when executing onRender function',
docsPageUrl: `${WEBSITE_URL}/docs/errors/on-render-error`,
},
{
name: 'prop_align_not_supported',
message: 'Only a div with props section can have props alignX and alignY',
docsPageUrl: `${WEBSITE_URL}/docs/errors/prop-align-not-supported`,
},
{
name: 'prop_padding_not_supported',
message: 'Only a div with props container can have prop padding',
docsPageUrl: `${WEBSITE_URL}/docs/errors/prop-padding-not-supported`,
},
{
name: 'src_is_required',
message: 'You must enter a src for the img tag',
docsPageUrl: `${WEBSITE_URL}/docs/errors/src-is-required`,
},
{
name: 'alt_is_required',
message: 'You must enter a alt for the img tag',
docsPageUrl: `${WEBSITE_URL}/docs/errors/alt-is-required`,
},
{
name: 'image_not_found',
message: 'The image you are trying to use was not found',
docsPageUrl: `${WEBSITE_URL}/docs/errors/image-not-found`,
},
{
name: 'on_image_as_props',
message:
'You passed an image as props in your template, this is not allowed',
docsPageUrl: `${WEBSITE_URL}/docs/errors/on-image-as-props`,
},
{
name: 'href_is_required',
message:
'You must enter a href for the a/button tag and it must be a string that starts with http',
docsPageUrl: `${WEBSITE_URL}/docs/errors/href-is-required`,
},
{
name: 'invalid_h_tag',
message: 'You used an invalid h tag. It must be h1, h2, h3, h4, h5 or h6',
docsPageUrl: `${WEBSITE_URL}/docs/errors/invalid-h-tag`,
},
{
name: 'invalid_storage_type',
message: 'Invalid storage type',
docsPageUrl: `${WEBSITE_URL}/docs/errors/invalid-storage-type`,
},
{
name: 'invalid_file_type',
message: 'Invalid file type',
docsPageUrl: `${WEBSITE_URL}/docs/errors/invalid-file-type`,
},
{
name: 'upload_error',
message: 'Error uploading image',
docsPageUrl: `${WEBSITE_URL}/docs/errors/upload-error`,
},
{
name: 'fails_to_prepare_image',
message: 'Error when optimizing or uploading image',
docsPageUrl: `${WEBSITE_URL}/docs/errors/fails-to-prepare-image`,
},
{
name: 'aws_access_key_id_not_found',
message: 'When using aws s3 storage, you must enter awsAccessKeyId',
docsPageUrl: `${WEBSITE_URL}/docs/errors/aws-access-key-id-not-found`,
},
{
name: 'aws_secret_access_key_not_found',
message: 'When using aws s3 storage, you must enter awsSecretAccessKey',
docsPageUrl: `${WEBSITE_URL}/docs/errors/aws-secret-access-key-not-found`,
},
{
name: 'aws_bucket_not_found',
message: 'When using aws s3 storage, you must enter awsBucket',
docsPageUrl: `${WEBSITE_URL}/docs/errors/aws-bucket-not-found`,
},
{
name: 'aws_region_not_found',
message: 'When using aws s3 storage, you must enter awsRegion',
docsPageUrl: `${WEBSITE_URL}/docs/errors/aws-region-not-found`,
},
{
name: 'no_built_dir',
message: 'You must to run the prepare command before the render',
docsPageUrl: `${WEBSITE_URL}/docs/errors/no-built-dir`,
},
{
name: 'built_dir_is_not_directory',
message: 'There is a problem with the builtDirPath you entered',
docsPageUrl: `${WEBSITE_URL}/docs/errors/built-dir-is-not-directory`,
},
{
name: 'undefined_child',
message: 'Some child is undefined. Please check your template',
docsPageUrl: `${WEBSITE_URL}/docs/errors/undefined-child`,
solutions: [
'Maybe you just forgot to return something in your onRender function',
'Maybe you forgot to return something in your template function',
Expand All @@ -189,7 +155,6 @@ export const ERRORS: IError[] = [
{
name: 'template_not_found',
message: 'Template not found',
docsPageUrl: `${WEBSITE_URL}/docs/errors/template-not-found`,
solutions: [
'Maybe you did not create a template with the name you passed',
'Maybe you did not run the prepare command after creating the template',
Expand All @@ -199,14 +164,12 @@ export const ERRORS: IError[] = [
name: 'font_invalid_href',
message:
'You must pass a valid href to the font tag. It must be a string that starts with http',
docsPageUrl: `${WEBSITE_URL}/docs/errors/font-invalid-href`,
},
];

export default class CoreError implements IError {
message: string;
name: string;
docsPageUrl: string;
solutions?: string[];
fileContext?: string;
customJson?: any;
Expand All @@ -217,7 +180,6 @@ export default class CoreError implements IError {
if (hasAnotherError) {
this.message = hasAnotherError.message;
this.name = hasAnotherError.name;
this.docsPageUrl = hasAnotherError.docsPageUrl;
this.solutions = hasAnotherError.solutions;
this.customJson = hasAnotherError.customJson;
this.fileContext = hasAnotherError.fileContext;
Expand All @@ -230,7 +192,6 @@ export default class CoreError implements IError {

this.message = error.message;
this.name = error.name;
this.docsPageUrl = error.docsPageUrl;
this.customJson = customJson;

if (error.solutions) {
Expand Down
1 change: 0 additions & 1 deletion packages/jsx-mail/src/utils/show-core-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ export default function showCoreError(error: any) {
message: error.message,
...(error.customJson ? error.customJson : {}),
...(error.solutions ? { solutions: error.solutions } : {}),
...(error.docsPageUrl ? { site: error.docsPageUrl } : {}),
});
}

1 comment on commit e47490e

@vercel
Copy link

@vercel vercel bot commented on e47490e Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.