8
0

ckeditorerror.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * @license Copyright (c) 2003-2016, 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. export default class CKEditorError extends Error {
  18. /**
  19. * Creates an instance of the CKEditorError class.
  20. *
  21. * Read more about error logging in the {@link core.log} module.
  22. *
  23. * @constructor
  24. * @param {String} message The error message in an `error-name: Error message.` format.
  25. * During the minification process the "Error message" part will be removed to limit the code size
  26. * and a link to this error documentation will be added to the `message`.
  27. * @param {Object} [data] Additional data describing the error. A stringified version of this object
  28. * will be appended to the error {@link #message}, so the data are quickly visible in the console. The original
  29. * data object will also be later available under the {@link #data} property.
  30. */
  31. constructor( message, data ) {
  32. if ( data ) {
  33. message += ' ' + JSON.stringify( data );
  34. }
  35. super( message );
  36. this.name = 'CKEditorError';
  37. /**
  38. * The additional error data passed to the constructor.
  39. *
  40. * @type {Object}
  41. */
  42. this.data = data;
  43. }
  44. }