ckeditorerror.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. * @memberOf core
  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. * @param {String} message The error message in an `error-name: Error message.` format.
  24. * During the minification process the "Error message" part will be removed to limit the code size
  25. * and a link to this error documentation will be added to the `message`.
  26. * @param {Object} [data] Additional data describing the error. A stringified version of this object
  27. * will be appended to the error {@link #message}, so the data are quickly visible in the console. The original
  28. * data object will also be later available under the {@link #data} property.
  29. */
  30. constructor( message, data ) {
  31. if ( data ) {
  32. message += ' ' + JSON.stringify( data );
  33. }
  34. super( message );
  35. /**
  36. * @member {String} core.CKEditorError#name
  37. */
  38. this.name = 'CKEditorError';
  39. /**
  40. * The additional error data passed to the constructor.
  41. *
  42. * @member {Object} core.CKEditorError#data
  43. */
  44. this.data = data;
  45. }
  46. }