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