source: trunk/web/addons/job_monarch/lib/extjs-30/src/core/Error.js @ 625

Last change on this file since 625 was 625, checked in by ramonb, 15 years ago

lib/extjs-30:

  • new ExtJS 3.0
File size: 2.2 KB
Line 
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 */
13Ext.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
27url / function. Please review your Proxy url/api-configuration."
28 * </pre><pre>
29"Could not locate your "root" property in your server response.
30Please review your JsonReader config to ensure the config-property
31"root" matches the property your server-response.  See the JsonReader
32docs for additional assistance."
33 * </pre>
34 * <p>An example of the code used for generating error messages:</p><pre><code>
35try {
36    generateError({
37        foo: 'bar'
38    });
39}
40catch (e) {
41    console.error(e);
42}
43function generateError(data) {
44    throw new Ext.Error('foo-error', data);
45}
46 * </code></pre>
47 * @param {String} message
48 */
49Ext.Error = function(message) {
50    // Try to read the message from Ext.Error.lang
51    this.message = (this.lang[message]) ? this.lang[message] : message;
52}
53Ext.Error.prototype = new Error();
54Ext.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
Note: See TracBrowser for help on using the repository browser.