source: Dev/trunk/src/client/dojo/errors/create.js @ 485

Last change on this file since 485 was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 980 bytes
Line 
1define(["../_base/lang"], function(lang){
2        return function(name, ctor, base, props){
3                base = base || Error;
4
5                var ErrorCtor = function(message){
6                        if(base === Error){
7                                if(Error.captureStackTrace){
8                                        Error.captureStackTrace(this, ErrorCtor);
9                                }
10
11                                // Error.call() operates on the returned error
12                                // object rather than operating on |this|
13                                var err = Error.call(this, message),
14                                        prop;
15
16                                // Copy own properties from err to |this|
17                                for(prop in err){
18                                        if(err.hasOwnProperty(prop)){
19                                                this[prop] = err[prop];
20                                        }
21                                }
22
23                                // messsage is non-enumerable in ES5
24                                this.message = message;
25                                // stack is non-enumerable in at least Firefox
26                                this.stack = err.stack;
27                        }else{
28                                base.apply(this, arguments);
29                        }
30                        if(ctor){
31                                ctor.apply(this, arguments);
32                        }
33                };
34
35                ErrorCtor.prototype = lang.delegate(base.prototype, props);
36                ErrorCtor.prototype.name = name;
37                ErrorCtor.prototype.constructor = ErrorCtor;
38
39                return ErrorCtor;
40        };
41});
Note: See TracBrowser for help on using the repository browser.