X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/docs/output/Ext.Error.js diff --git a/docs/output/Ext.Error.js b/docs/output/Ext.Error.js new file mode 100644 index 00000000..4db80ecb --- /dev/null +++ b/docs/output/Ext.Error.js @@ -0,0 +1 @@ +Ext.data.JsonP.Ext_Error({"tagname":"class","html":"

Hierarchy

Error
Ext.Error

Files

A wrapper class for the native JavaScript Error object that adds a few useful capabilities for handling\nerrors in an Ext application. When you use Ext.Error to raise an error from within any class that\nuses the Ext 4 class system, the Error class can automatically add the source class and method from which\nthe error was raised. It also includes logic to automatically log the eroor to the console, if available,\nwith additional metadata about the error. In all cases, the error will always be thrown at the end so that\nexecution will halt.

\n\n

Ext.Error also offers a global error handling method that can be overridden in order to\nhandle application-wide errors in a single spot. You can optionally ignore errors altogether,\nalthough in a real application it's usually a better idea to override the handling function and perform\nlogging or some other method of reporting the errors in a way that is meaningful to the application.

\n\n

At its simplest you can simply raise an error as a simple string from within any code:

\n\n

Example usage:

\n\n
Ext.Error.raise('Something bad happened!');\n
\n\n

If raised from plain JavaScript code, the error will be logged to the console (if available) and the message\ndisplayed. In most cases however you'll be raising errors from within a class, and it may often be useful to add\nadditional metadata about the error being raised. The raise method can also take a config object.\nIn this form the msg attribute becomes the error description, and any other data added to the config gets\nadded to the error object and, if the console is available, logged to the console for inspection.

\n\n

Example usage:

\n\n
Ext.define('Ext.Foo', {\n    doSomething: function(option){\n        if (someCondition === false) {\n            Ext.Error.raise({\n                msg: 'You cannot do that!',\n                option: option,   // whatever was passed into the method\n                'error code': 100 // other arbitrary info\n            });\n        }\n    }\n});\n
\n\n

If a console is available (that supports the console.dir function) you'll see console output like:

\n\n
An error was raised with the following data:\noption:         Object { foo: \"bar\"}\n    foo:        \"bar\"\nerror code:     100\nmsg:            \"You cannot do that!\"\nsourceClass:   \"Ext.Foo\"\nsourceMethod:  \"doSomething\"\n\nuncaught exception: You cannot do that!\n
\n\n

As you can see, the error will report exactly where it was raised and will include as much information as the\nraising code can usefully provide.

\n\n

If you want to handle all application errors globally you can simply override the static handle method\nand provide whatever handling logic you need. If the method returns true then the error is considered handled\nand will not be thrown to the browser. If anything but true is returned then the error will be thrown normally.

\n\n

Example usage:

\n\n
Ext.Error.handle = function(err) {\n    if (err.someProperty == 'NotReallyAnError') {\n        // maybe log something to the application here if applicable\n        return true;\n    }\n    // any non-true return value (including none) will cause the error to be thrown\n}\n
\n

Properties

Defined By

Static Properties

Static flag that can be used to globally disable error reporting to the browser if set to true\n(defaults to false). ...

Static flag that can be used to globally disable error reporting to the browser if set to true\n(defaults to false). Note that if you ignore Ext errors it's likely that some other code may fail\nand throw a native JavaScript error thereafter, so use with caution. In most cases it will probably\nbe preferable to supply a custom error handling function instead.

\n\n

Example usage:

\n\n
Ext.Error.ignore = true;\n
\n
Static flag that can be used to globally control error notification to the user. ...

Static flag that can be used to globally control error notification to the user. Unlike\nEx.Error.ignore, this does not effect exceptions. They are still thrown. This value can be\nset to false to disable the alert notification (default is true for IE6 and IE7).

\n\n

Only the first error will generate an alert. Internally this flag is set to false when the\nfirst error occurs prior to displaying the alert.

\n\n

This flag is not used in a release build.

\n\n

Example usage:

\n\n
Ext.Error.notify = false;\n
\n

Methods

Defined By

Instance Methods

Creates new Error object. ...

Creates new Error object.

\n

Parameters

  • config : String/Object

    The error message string, or an object containing the\nattribute \"msg\" that will be used as the error message. Any other data included in\nthe object will be applied to the error instance and logged to the browser console, if available.

    \n

Returns

Provides a custom string representation of the error object. ...

Provides a custom string representation of the error object. This is an override of the base JavaScript\nObject.toString method, which is useful so that when logged to the browser console, an error object will\nbe displayed with a useful message instead of [object Object], the default toString result.

\n\n

The default implementation will include the error message along with the raising class and method, if available,\nbut this can be overridden with a custom implementation either at the prototype level (for all errors) or on\na particular error instance, if you want to provide a custom description that will show up in the console.

\n

Returns

  • String

    The error message. If raised from within the Ext 4 class system, the error message will also\ninclude the raising class and method names, if available.

    \n
Defined By

Static Methods

Globally handle any Ext errors that may be raised, optionally providing custom logic to\nhandle different errors indiv...

Globally handle any Ext errors that may be raised, optionally providing custom logic to\nhandle different errors individually. Return true from the function to bypass throwing the\nerror to the browser, otherwise the error will be thrown and execution will halt.

\n\n

Example usage:

\n\n
Ext.Error.handle = function(err) {\n    if (err.someProperty == 'NotReallyAnError') {\n        // maybe log something to the application here if applicable\n        return true;\n    }\n    // any non-true return value (including none) will cause the error to be thrown\n}\n
\n

Parameters

  • err : Ext.Error

    The Ext.Error object being raised. It will contain any attributes that were originally\nraised with it, plus properties about the method and class from which the error originated (if raised from a\nclass that uses the Ext 4 class system).

    \n
Raise an error that can include additional data and supports automatic console logging if available. ...

Raise an error that can include additional data and supports automatic console logging if available.\nYou can pass a string error message or an object with the msg attribute which will be used as the\nerror message. The object can contain any other name-value attributes (or objects) to be logged\nalong with the error.

\n\n

Note that after displaying the error message a JavaScript error will ultimately be thrown so that\nexecution will halt.

\n\n

Example usage:

\n\n
Ext.Error.raise('A simple string error message');\n\n// or...\n\nExt.define('Ext.Foo', {\n    doSomething: function(option){\n        if (someCondition === false) {\n            Ext.Error.raise({\n                msg: 'You cannot do that!',\n                option: option,   // whatever was passed into the method\n                'error code': 100 // other arbitrary info\n            });\n        }\n    }\n});\n
\n

Parameters

  • err : String/Object

    The error message string, or an object containing the attribute \"msg\" that will be\nused as the error message. Any other data included in the object will also be logged to the browser console,\nif available.

    \n
","allMixins":[],"meta":{"author":["Brian Moeskau "],"docauthor":["Brian Moeskau "]},"requires":[],"deprecated":null,"extends":"Error","inheritable":false,"static":false,"superclasses":[],"singleton":false,"code_type":"assignment","alias":null,"statics":{"property":[{"tagname":"property","deprecated":null,"static":true,"owner":"Ext.Error","template":null,"required":null,"protected":false,"name":"ignore","id":"static-property-ignore"},{"tagname":"property","deprecated":null,"static":true,"owner":"Ext.Error","template":null,"required":null,"protected":false,"name":"notify","id":"static-property-notify"}],"css_var":[],"css_mixin":[],"cfg":[],"method":[{"tagname":"method","deprecated":null,"static":true,"owner":"Ext.Error","template":false,"required":null,"protected":false,"name":"handle","id":"static-method-handle"},{"tagname":"method","deprecated":null,"static":true,"owner":"Ext.Error","template":false,"required":null,"protected":false,"name":"raise","id":"static-method-raise"}],"event":[]},"subclasses":[],"uses":[],"protected":false,"mixins":[],"members":{"property":[],"css_var":[],"css_mixin":[],"cfg":[],"method":[{"tagname":"method","deprecated":null,"static":false,"owner":"Ext.Error","template":false,"required":null,"protected":false,"name":"constructor","id":"method-constructor"},{"tagname":"method","deprecated":null,"static":false,"owner":"Ext.Error","template":false,"required":null,"protected":false,"name":"toString","id":"method-toString"}],"event":[]},"private":false,"component":false,"name":"Ext.Error","alternateClassNames":[],"id":"class-Ext.Error","mixedInto":[],"xtypes":{},"files":[{"href":"Error.html#Ext-Error","filename":"Error.js"}]}); \ No newline at end of file