8
0

ckeditorerror.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. /**
  7. * The CKEditor error class.
  8. *
  9. * All errors will be shortened during the minification process in order to reduce the code size.
  10. * Therefore, all error messages should be documented in the same way as those in {@link CKEDITOR.core.log}.
  11. *
  12. * Read more in the {@link core.log} module.
  13. *
  14. * @class CKEditorError
  15. * @extends Error
  16. */
  17. CKEDITOR.define( () => {
  18. class CKEditorError extends Error {
  19. /**
  20. * Creates an instance of the CKEditorError class.
  21. *
  22. * Read more about error logging in the {@link core.log} module.
  23. *
  24. * @constructor
  25. * @param {String} message The error message in an `error-name: Error message.` format.
  26. * During the minification process the "Error message" part will be removed to limit the code size
  27. * and a link to this error documentation will be added to the `message`.
  28. * @param {Object} [data] Additional data describing the error. A stringified version of this object
  29. * will be appended to the error {@link #message}, so the data are quickly visible in the console. The original
  30. * data object will also be later available under the {@link #data} property.
  31. */
  32. constructor( message, data ) {
  33. if ( data ) {
  34. message += ' ' + JSON.stringify( data );
  35. }
  36. super( message );
  37. this.name = 'CKEditorError';
  38. /**
  39. * The additional error data passed to the constructor.
  40. *
  41. * @property {Object} data
  42. */
  43. this.data = data;
  44. }
  45. }
  46. return CKEditorError;
  47. } );