1 | /*! |
---|
2 | * Ext JS Library 3.0.0 |
---|
3 | * Copyright(c) 2006-2009 Ext JS, LLC |
---|
4 | * licensing@extjs.com |
---|
5 | * http://www.extjs.com/license |
---|
6 | */ |
---|
7 | /** |
---|
8 | * Framework-wide error-handler. Developers can override this method to provide |
---|
9 | * custom exception-handling. Framework errors will often extend from the base |
---|
10 | * Ext.Error class. |
---|
11 | * @param {Object/Error} e The thrown exception object. |
---|
12 | */ |
---|
13 | Ext.handleError = function(e) { |
---|
14 | throw e; |
---|
15 | }; |
---|
16 | |
---|
17 | /** |
---|
18 | * @class Ext.Error |
---|
19 | * @extends Error |
---|
20 | * <p>A base error class. Future implementations are intended to provide more |
---|
21 | * robust error handling throughout the framework (<b>in the debug build only</b>) |
---|
22 | * to check for common errors and problems. The messages issued by this class |
---|
23 | * will aid error checking. Error checks will be automatically removed in the |
---|
24 | * production build so that performance is not negatively impacted.</p> |
---|
25 | * <p>Some sample messages currently implemented:</p><pre> |
---|
26 | "DataProxy attempted to execute an API-action but found an undefined |
---|
27 | url / function. Please review your Proxy url/api-configuration." |
---|
28 | * </pre><pre> |
---|
29 | "Could not locate your "root" property in your server response. |
---|
30 | Please review your JsonReader config to ensure the config-property |
---|
31 | "root" matches the property your server-response. See the JsonReader |
---|
32 | docs for additional assistance." |
---|
33 | * </pre> |
---|
34 | * <p>An example of the code used for generating error messages:</p><pre><code> |
---|
35 | try { |
---|
36 | generateError({ |
---|
37 | foo: 'bar' |
---|
38 | }); |
---|
39 | } |
---|
40 | catch (e) { |
---|
41 | console.error(e); |
---|
42 | } |
---|
43 | function generateError(data) { |
---|
44 | throw new Ext.Error('foo-error', data); |
---|
45 | } |
---|
46 | * </code></pre> |
---|
47 | * @param {String} message |
---|
48 | */ |
---|
49 | Ext.Error = function(message) { |
---|
50 | // Try to read the message from Ext.Error.lang |
---|
51 | this.message = (this.lang[message]) ? this.lang[message] : message; |
---|
52 | } |
---|
53 | Ext.Error.prototype = new Error(); |
---|
54 | Ext.apply(Ext.Error.prototype, { |
---|
55 | // protected. Extensions place their error-strings here. |
---|
56 | lang: {}, |
---|
57 | |
---|
58 | name: 'Ext.Error', |
---|
59 | /** |
---|
60 | * getName |
---|
61 | * @return {String} |
---|
62 | */ |
---|
63 | getName : function() { |
---|
64 | return this.name; |
---|
65 | }, |
---|
66 | /** |
---|
67 | * getMessage |
---|
68 | * @return {String} |
---|
69 | */ |
---|
70 | getMessage : function() { |
---|
71 | return this.message; |
---|
72 | }, |
---|
73 | /** |
---|
74 | * toJson |
---|
75 | * @return {String} |
---|
76 | */ |
---|
77 | toJson : function() { |
---|
78 | return Ext.encode(this); |
---|
79 | } |
---|
80 | }); |
---|
81 | |
---|