home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2014 January / PCgo_CD_14_01.iso / interface / lib / utils / ErrorHandler.js
Encoding:
Text File  |  2013-04-05  |  2.0 KB  |  68 lines

  1. /**
  2.  * Dieser Konstruktor beinhaltet Methoden zur Fehlerbehandlung. 
  3.  * 
  4.  ---
  5.  EvalError: An error in the eval() function has occurred.
  6.  
  7.  RangeError: Out of range number value has occurred.
  8.  
  9.  ReferenceError: An illegal reference has occurred.
  10.  
  11.  SyntaxError: A syntax error within code inside the eval() function has occurred. All other syntax errors are not caught by try/catch/finally, and will trigger the default browser error message associated with the error. To catch actual syntax errors, you may use the onerror event.
  12.  
  13.  TypeError: An error in the expected variable type has occurred.
  14.  
  15.  URIError: An error when encoding or decoding the URI has occurred (ie: when calling encodeURI()).
  16.  
  17.  * @namespace IM
  18.  * @class ErrorHandler
  19.  * @constructor 
  20.  */
  21. IM.ErrorHandler = function () {
  22.     
  23.     /**
  24.      * Handhabt die Fehlerausgabe in der Konsole.
  25.      * @method throwError
  26.      * @param {String} msg Der Text der Fehlermeldung.
  27.      * @param {String} type Gibt den Fehlertyp an (Eval-, Range-, Reference-, Syntax-, Type-, Uri-Error).
  28.      */
  29.     var throwError = function ( msg, type ) {
  30.         
  31.         switch ( type ) {
  32.             case 'eval':
  33.                 throw EvalError( msg );
  34.                 break;
  35.             case 'range':
  36.                 throw RangeError( msg );
  37.                 break;
  38.             case 'ref':
  39.                 throw ReferenceError( msg );
  40.                 break;
  41.             case 'syntax':
  42.                 throw SyntaxError( msg );
  43.                 break;
  44.             case 'type':
  45.                 throw TypeError( msg );
  46.                 break;
  47.             case 'uri':
  48.                 throw URIError( msg );
  49.                 break;
  50.             default:
  51.                 throw new Error( msg );
  52.                 break;
  53.         }
  54.         
  55.     };
  56.     
  57.     return {
  58.         errorMsg: function ( msg, type  ) {
  59.             
  60.             var type = type || '',
  61.             msg = msg || 'Fehlerbeschreibung fehlt!';
  62.             
  63.             throwError( msg, type );
  64.             
  65.         }
  66.     };
  67.     
  68. }();