home *** CD-ROM | disk | FTP | other *** search
- var CustomErrors = {
- };
-
- CustomErrors.ECustom = Base.extend({
- $name: "ECustom",
-
- constructor: function ECustom_constructor(message) {
- this._stackFrame = Components.stack.caller.caller.caller.caller;
- if (message)
- this._message = message.toString();
- },
-
- get name() {
- return this.$class.$name;
- },
-
- get message() {
- return this._message + " (" + this._details + ")";
- },
-
- get fileName() {
- return this._stackFrame.filename;
- },
-
- get lineNumber() {
- return this._stackFrame.lineNumber;
- },
-
- get stack() {
- return this._makeStackStr(this._stackFrame);
- },
-
- toString: function ECustom_toString() {
- return this.name + ": " + this.message;
- },
-
- _stackFrame: null,
- _details: undefined,
- _message: undefined,
-
- _makeStackStr: function ECustom_makeStackStr(stackFrame) {
- var result = "";
- do {
- let frameLine = stackFrame.name + "(...)@" + stackFrame.filename + ":" + stackFrame.lineNumber + "\n";
- result += frameLine;
- stackFrame = stackFrame.caller;
- } while (stackFrame);
- return result;
- }
- });
-
- CustomErrors.EArgType = CustomErrors.ECustom.extend({
- $name: "EArgType",
-
- constructor: function EArgType_constructor(argName, expectedTypeName, actualTypeName) {
- this.base("Argument type missmatch");
- this._argName = argName.toString();
- this._expectedTypeName = expectedTypeName.toString();
- this._actualTypeName = actualTypeName.toString();
- },
-
- get _details() {
- return [this._argName, this._expectedTypeName, this._actualTypeName];
- },
-
- _argName: undefined,
- _expectedTypeName: undefined,
- _actualTypeName: undefined
- });
-
- CustomErrors.ENoInterface = CustomErrors.ECustom.extend({
- $name: "ENoInterface",
-
- constructor: function ENoInterface_constructor(interfaceName) {
- this.base("Unsupported interface");
- this._intfName = interfaceName.toString();
- },
-
- get _details() {
- return this._intfName;
- },
-
- _intfName: undefined
- });
-
- CustomErrors.ESecurityViolation = CustomErrors.ECustom.extend({
- $name: "ESecurityViolation",
-
- constructor: function ESecViol_constructor(where, what) {
- this.base("Security violation");
- this._where = where.toString();
- this._what = what.toString();
- },
-
- get _details() {
- return [this._where, this._what];
- },
-
- _where: undefined,
- _what: undefined
- });
-
- CustomErrors.EDownload = CustomErrors.ECustom.extend({
- $name: "EDownload",
-
- constructor: function EDownload_constructor(uri, reason) {
- this.base("Download error");
- this._uri = uri.toString();
- this._reason = reason.toString();
- },
-
- get _details() {
- return [this._uri, this._reason];
- },
-
- _uri: undefined,
- _reason: undefined
- });
-