From e6e8890aac57f9cf001196a08bfdc9c91d8e43da Mon Sep 17 00:00:00 2001 From: nshenderov Date: Fri, 20 Dec 2024 09:54:55 +0300 Subject: [PATCH] chore: update error messages --- admin/src/components/CKEReact.tsx | 4 ++-- admin/src/components/EditorProvider.tsx | 6 +++++- admin/src/config/language.ts | 2 +- admin/src/plugins/StrapiMediaLib.ts | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/admin/src/components/CKEReact.tsx b/admin/src/components/CKEReact.tsx index 9e79d48..b833800 100644 --- a/admin/src/components/CKEReact.tsx +++ b/admin/src/components/CKEReact.tsx @@ -46,7 +46,7 @@ export function CKEReact() { const handleChangeAssets = useCallback( (newElems: string): void => { if (!editorInstance) { - throw new Error('CKEditor: Editor instance is not initialized'); + throw new Error('The editor instance has not been initialized.'); } const viewFragment = editorInstance.data.processor.toView(newElems); @@ -94,7 +94,7 @@ export function CKEReact() { try { setUpFn(editor); } catch (err) { - console.error(`CKEditor: Error setting up ${pluginName} plugin `, err); + console.error(`Failed to set up the ${pluginName} plugin `, err); } } }); diff --git a/admin/src/components/EditorProvider.tsx b/admin/src/components/EditorProvider.tsx index 5ba1ad7..e86fb63 100644 --- a/admin/src/components/EditorProvider.tsx +++ b/admin/src/components/EditorProvider.tsx @@ -27,7 +27,11 @@ const EditorContext = createContext(null); export function useEditorContext(): EditorContextValue { const context = useContext(EditorContext); - if (!context) throw Error('useEditorAttributes can only be used inside EditorProvider'); + + if (!context) { + throw new Error('The useEditorContext hook must be used within the EditorProvider.'); + } + return context; } diff --git a/admin/src/config/language.ts b/admin/src/config/language.ts index e37e2a9..0557a0e 100644 --- a/admin/src/config/language.ts +++ b/admin/src/config/language.ts @@ -49,7 +49,7 @@ async function importLang(config: EditorConfig, language: string): Promise TRANSLATIONS[language] = translation.default; config.translations = translation.default; } else { - console.warn(`CKEditor: no translation found for language: ${language}`); + console.warn(`No CKEditor translation found for language: ${language}`); } } diff --git a/admin/src/plugins/StrapiMediaLib.ts b/admin/src/plugins/StrapiMediaLib.ts index 61f9cfd..41d3a86 100644 --- a/admin/src/plugins/StrapiMediaLib.ts +++ b/admin/src/plugins/StrapiMediaLib.ts @@ -41,7 +41,7 @@ export class StrapiMediaLib extends Plugin implements StrapiMediaLibPlugin { public connect(strapiToggle: () => void): void { if (typeof strapiToggle !== 'function') { - throw new Error('Input parameter for toogle should be a function'); + throw new Error('The input parameter for toggle must be a function.'); } this.strapiToggle = strapiToggle; @@ -50,7 +50,7 @@ export class StrapiMediaLib extends Plugin implements StrapiMediaLibPlugin { public toggle(): void { if (typeof this.strapiToggle !== 'function') { throw new Error( - 'Strapi media library toggle function not connected. Use connect function first' + 'The Strapi Media Library toggle function is not connected. Use the connect function first.' ); }