home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / AIMP2 / aimp_2.61.583.exe / $TEMP / YandexPackSetup.msi / fil2D620DB3714B2C0222E8DC49958F4853 < prev    next >
Text File  |  2010-07-12  |  3KB  |  119 lines

  1. var CustomErrors = {
  2. };
  3.  
  4. CustomErrors.ECustom = Base.extend({
  5.     $name: "ECustom",
  6.     
  7.     constructor: function ECustom_constructor(message) {
  8.         this._stackFrame = Components.stack.caller.caller.caller.caller;
  9.         if (message)
  10.             this._message = message.toString();
  11.     },
  12.     
  13.     get name() {
  14.         return this.$class.$name;
  15.     },
  16.     
  17.     get message() {
  18.         return this._message + " (" + this._details + ")";
  19.     },
  20.     
  21.     get fileName() {
  22.         return this._stackFrame.filename;
  23.     },
  24.     
  25.     get lineNumber() {
  26.         return this._stackFrame.lineNumber;
  27.     },
  28.     
  29.     get stack() {
  30.         return this._makeStackStr(this._stackFrame);
  31.     },
  32.     
  33.     toString: function ECustom_toString() {
  34.         return this.name + ": " + this.message;
  35.     },
  36.     
  37.     _stackFrame: null,
  38.     _details: undefined,
  39.     _message: undefined,
  40.     
  41.     _makeStackStr: function ECustom_makeStackStr(stackFrame) {
  42.         var result = "";
  43.         do {
  44.             let frameLine = stackFrame.name + "(...)@" + stackFrame.filename + ":" + stackFrame.lineNumber + "\n";
  45.             result += frameLine;
  46.             stackFrame = stackFrame.caller;
  47.         } while (stackFrame);
  48.         return result;
  49.     }
  50. });
  51.  
  52. CustomErrors.EArgType = CustomErrors.ECustom.extend({
  53.     $name: "EArgType",
  54.     
  55.     constructor: function EArgType_constructor(argName, expectedTypeName, actualTypeName) {
  56.         this.base("Argument type missmatch");
  57.         this._argName = argName.toString();
  58.         this._expectedTypeName = expectedTypeName.toString();
  59.         this._actualTypeName = actualTypeName.toString();
  60.     },
  61.     
  62.     get _details() {
  63.         return [this._argName, this._expectedTypeName, this._actualTypeName];
  64.     },
  65.     
  66.     _argName: undefined,
  67.     _expectedTypeName: undefined,
  68.     _actualTypeName: undefined
  69. });
  70.  
  71. CustomErrors.ENoInterface = CustomErrors.ECustom.extend({
  72.     $name: "ENoInterface",
  73.     
  74.     constructor: function ENoInterface_constructor(interfaceName) {
  75.         this.base("Unsupported interface");
  76.         this._intfName = interfaceName.toString();
  77.     },
  78.     
  79.     get _details() {
  80.         return this._intfName;
  81.     },
  82.     
  83.     _intfName: undefined
  84. });
  85.  
  86. CustomErrors.ESecurityViolation = CustomErrors.ECustom.extend({
  87.     $name: "ESecurityViolation",
  88.     
  89.     constructor: function ESecViol_constructor(where, what) {
  90.         this.base("Security violation");
  91.         this._where = where.toString();
  92.         this._what = what.toString();
  93.     },
  94.     
  95.     get _details() {
  96.         return [this._where, this._what];
  97.     },
  98.     
  99.     _where: undefined,
  100.     _what: undefined
  101. });
  102.  
  103. CustomErrors.EDownload = CustomErrors.ECustom.extend({
  104.     $name: "EDownload",
  105.     
  106.     constructor: function EDownload_constructor(uri, reason) {
  107.         this.base("Download error");
  108.         this._uri = uri.toString();
  109.         this._reason = reason.toString();
  110.     },
  111.     
  112.     get _details() {
  113.         return [this._uri, this._reason];
  114.     },
  115.     
  116.     _uri: undefined,
  117.     _reason: undefined
  118. });
  119.