source:
trunk/workshop-routing-foss4g/web/ext/src/core/Error.js
@
76
Revision 76, 2.2 KB checked in by djay, 12 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /*! |
2 | * Ext JS Library 3.4.0 |
3 | * Copyright(c) 2006-2011 Sencha Inc. |
4 | * licensing@sencha.com |
5 | * http://www.sencha.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 | |
54 | Ext.Error.prototype = new Error(); |
55 | Ext.apply(Ext.Error.prototype, { |
56 | // protected. Extensions place their error-strings here. |
57 | lang: {}, |
58 | |
59 | name: 'Ext.Error', |
60 | /** |
61 | * getName |
62 | * @return {String} |
63 | */ |
64 | getName : function() { |
65 | return this.name; |
66 | }, |
67 | /** |
68 | * getMessage |
69 | * @return {String} |
70 | */ |
71 | getMessage : function() { |
72 | return this.message; |
73 | }, |
74 | /** |
75 | * toJson |
76 | * @return {String} |
77 | */ |
78 | toJson : function() { |
79 | return Ext.encode(this); |
80 | } |
81 | }); |
Note: See TracBrowser
for help on using the repository browser.