Friday, 3 January 2014

CRM 2011 JavaScript Error Handling

URIError:
This error occurs while encoding or decoding an URI. It is not a common occurrence in Dynamics CRM.

RangeError: 

This error occurs when the number is out of range. It has a quite
common occurrence when performing calculations, especially when
overriding the standard taxation in Dynamics CRM.


ReferenceError:
 

This error is caused by an illegal reference; this is returned in Internet Explorer as a TypeError.

EvalError: 

This error can be generated while using the eval() function. This is
also returned in Internet Explorer as a TypeError.


TypeError: 

This error is not as common anymore when defining most of your variables as var, but you will encounter this in the case of incorrect casting.

SyntaxError: 

Working in conjunction with EvalError, this error is thrown when there is a syntax error within the eval() function. This does not catch the standard syntax errors.


Sample :

function SampleErrorHandling()
{

 try
  {

   // throw new RangeError("This is a RangeError thrown...");
   // throw new TypeError("This is a TypeError thrown...");
   // throw new SyntaxError("This is a SyntaxError thrown...");
   // throw new Error("This is a Custom Error thrown...");
  }
 catch(err)
  {
   switch(err.name)
    {
     case "URIError":
     alert(err.name + " || " + err.message);
     break;
     case "RangeError":
     alert(err.name + " || " + err.message);
     case "TypeError":
     alert(err.name + " || " + err.message);
     break;
     case "SyntaxError":
     alert(err.name + " || " + err.message);
     break;
     case "CustomError":
     alert(err.name + " || " + err.message);
     break;
    }
   }
 finally
  {
   alert("This block executes at all times");
  }
}






 

No comments:

Post a Comment