@ckeditor/ckeditor5-utils 30.0.0 → 31.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/ckeditorerror.js +38 -3
- package/src/version.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "31.0.0",
|
|
4
4
|
"description": "Miscellaneous utilities used by CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"lodash-es": "^4.17.15"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@ckeditor/ckeditor5-build-classic": "^
|
|
18
|
-
"@ckeditor/ckeditor5-editor-classic": "^
|
|
19
|
-
"@ckeditor/ckeditor5-core": "^
|
|
20
|
-
"@ckeditor/ckeditor5-engine": "^
|
|
17
|
+
"@ckeditor/ckeditor5-build-classic": "^31.0.0",
|
|
18
|
+
"@ckeditor/ckeditor5-editor-classic": "^31.0.0",
|
|
19
|
+
"@ckeditor/ckeditor5-core": "^31.0.0",
|
|
20
|
+
"@ckeditor/ckeditor5-engine": "^31.0.0",
|
|
21
21
|
"assertion-error": "^1.1.0",
|
|
22
22
|
"js-beautify": "^1.11.0"
|
|
23
23
|
},
|
package/src/ckeditorerror.js
CHANGED
|
@@ -59,9 +59,7 @@ export default class CKEditorError extends Error {
|
|
|
59
59
|
* data object will also be later available under the {@link #data} property.
|
|
60
60
|
*/
|
|
61
61
|
constructor( errorName, context, data ) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
super( message );
|
|
62
|
+
super( getErrorMessage( errorName, data ) );
|
|
65
63
|
|
|
66
64
|
/**
|
|
67
65
|
* @type {String}
|
|
@@ -172,10 +170,47 @@ export function logError( errorName, data ) {
|
|
|
172
170
|
console.error( ...formatConsoleArguments( errorName, data ) );
|
|
173
171
|
}
|
|
174
172
|
|
|
173
|
+
// Returns formatted link to documentation message.
|
|
174
|
+
//
|
|
175
|
+
// @private
|
|
176
|
+
// @param {String} errorName
|
|
177
|
+
// @returns {string}
|
|
175
178
|
function getLinkToDocumentationMessage( errorName ) {
|
|
176
179
|
return `\nRead more: ${ DOCUMENTATION_URL }#error-${ errorName }`;
|
|
177
180
|
}
|
|
178
181
|
|
|
182
|
+
// Returns formatted error message.
|
|
183
|
+
//
|
|
184
|
+
// @private
|
|
185
|
+
// @param {String} errorName
|
|
186
|
+
// @param {Object} [data]
|
|
187
|
+
// @returns {string}
|
|
188
|
+
function getErrorMessage( errorName, data ) {
|
|
189
|
+
const processedObjects = new WeakSet();
|
|
190
|
+
const circularReferencesReplacer = ( key, value ) => {
|
|
191
|
+
if ( typeof value === 'object' && value !== null ) {
|
|
192
|
+
if ( processedObjects.has( value ) ) {
|
|
193
|
+
return `[object ${ value.constructor.name }]`;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
processedObjects.add( value );
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return value;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const stringifiedData = data ? ` ${ JSON.stringify( data, circularReferencesReplacer ) }` : '';
|
|
203
|
+
const documentationLink = getLinkToDocumentationMessage( errorName );
|
|
204
|
+
|
|
205
|
+
return errorName + stringifiedData + documentationLink;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Returns formatted console error arguments.
|
|
209
|
+
//
|
|
210
|
+
// @private
|
|
211
|
+
// @param {String} errorName
|
|
212
|
+
// @param {Object} [data]
|
|
213
|
+
// @returns {Array}
|
|
179
214
|
function formatConsoleArguments( errorName, data ) {
|
|
180
215
|
const documentationMessage = getLinkToDocumentationMessage( errorName );
|
|
181
216
|
|