function initException(Num,Msg)//define an Exception { this.ErrorNumber=Num;//error's number this.ErrorMessage=Msg;//error's message } function CreateException() { ex=new initException(1,"Created!");//create the excepion throw ex;//throw ex } function test() { try { CreateException(); } catch(ex)//catch the ex { if(ex instanceof initException)//if the exception is our target,do something { alert(ex.ErrorNumber+ex.ErrorMessage); } else//else throw again { throw ex; } } finally { alert("end");//do something finally } } </script>