Upgrade to ExtJS 3.2.0 - Released 03/30/2010
[extjs.git] / docs / source / Error.html
1 <html>
2 <head>
3   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
4   <title>The source code</title>
5     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 </head>
8 <body  onload="prettyPrint();">
9     <pre class="prettyprint lang-js">/*!
10  * Ext JS Library 3.2.0
11  * Copyright(c) 2006-2010 Ext JS, Inc.
12  * licensing@extjs.com
13  * http://www.extjs.com/license
14  */
15 <div id="method-Ext.EventManager-handleError"></div>/**
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  */
21 Ext.handleError = function(e) {
22     throw e;
23 };
24
25 <div id="cls-Ext.Error"></div>/**
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
62 Ext.Error.prototype = new Error();
63 Ext.apply(Ext.Error.prototype, {
64     // protected.  Extensions place their error-strings here.
65     lang: {},
66
67     name: 'Ext.Error',
68     <div id="method-Ext.Error-getName"></div>/**
69      * getName
70      * @return {String}
71      */
72     getName : function() {
73         return this.name;
74     },
75     <div id="method-Ext.Error-getMessage"></div>/**
76      * getMessage
77      * @return {String}
78      */
79     getMessage : function() {
80         return this.message;
81     },
82     <div id="method-Ext.Error-toJson"></div>/**
83      * toJson
84      * @return {String}
85      */
86     toJson : function() {
87         return Ext.encode(this);
88     }
89 });
90 </pre>    
91 </body>
92 </html>