PageRenderTime 63ms CodeModel.GetById 35ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/ext-3.4.1/src/core/Error.js

https://github.com/ouzo12/tvheadend
JavaScript | 96 lines | 20 code | 3 blank | 73 comment | 0 complexity | 766cac2c3c8e84f22e837af0d85e0c04 MD5 | raw file
Possible License(s): GPL-3.0
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. /**
  16. * Framework-wide error-handler. Developers can override this method to provide
  17. * custom exception-handling. Framework errors will often extend from the base
  18. * Ext.Error class.
  19. * @param {Object/Error} e The thrown exception object.
  20. * @member Ext
  21. */
  22. Ext.handleError = function(e) {
  23. throw e;
  24. };
  25. /**
  26. * @class Ext.Error
  27. * @extends Error
  28. * <p>A base error class. Future implementations are intended to provide more
  29. * robust error handling throughout the framework (<b>in the debug build only</b>)
  30. * to check for common errors and problems. The messages issued by this class
  31. * will aid error checking. Error checks will be automatically removed in the
  32. * production build so that performance is not negatively impacted.</p>
  33. * <p>Some sample messages currently implemented:</p><pre>
  34. "DataProxy attempted to execute an API-action but found an undefined
  35. url / function. Please review your Proxy url/api-configuration."
  36. * </pre><pre>
  37. "Could not locate your "root" property in your server response.
  38. Please review your JsonReader config to ensure the config-property
  39. "root" matches the property your server-response. See the JsonReader
  40. docs for additional assistance."
  41. * </pre>
  42. * <p>An example of the code used for generating error messages:</p><pre><code>
  43. try {
  44. generateError({
  45. foo: 'bar'
  46. });
  47. }
  48. catch (e) {
  49. console.error(e);
  50. }
  51. function generateError(data) {
  52. throw new Ext.Error('foo-error', data);
  53. }
  54. * </code></pre>
  55. * @param {String} message
  56. */
  57. Ext.Error = function(message) {
  58. // Try to read the message from Ext.Error.lang
  59. this.message = (this.lang[message]) ? this.lang[message] : message;
  60. };
  61. Ext.Error.prototype = new Error();
  62. Ext.apply(Ext.Error.prototype, {
  63. // protected. Extensions place their error-strings here.
  64. lang: {},
  65. name: 'Ext.Error',
  66. /**
  67. * getName
  68. * @return {String}
  69. */
  70. getName : function() {
  71. return this.name;
  72. },
  73. /**
  74. * getMessage
  75. * @return {String}
  76. */
  77. getMessage : function() {
  78. return this.message;
  79. },
  80. /**
  81. * toJson
  82. * @return {String}
  83. */
  84. toJson : function() {
  85. return Ext.encode(this);
  86. }
  87. });