1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>[Test throw]</title>
<style type="text/css">
* {
font-family : Verdana;
font-size : 13px;
}
#console {
border : 1px solid red;
padding : 5px;
}
</style>
<script type="text/javascript">
function debug( msg){
var oDebug = document.getElementById('console');
if( !oDebug){
oDebug = document.createElement('div');
oDebug.id = 'console';
document.body.insertBefore(oDebug ,document.body.firstChild);
}
oDebug.innerHTML += msg +'<br>';
}
var nbError = -1;
function fctErreur(){
var x;
try{
nbError++;
if( nbError == 0){
x += non_defini; // VRAI Erreur ICI
}
throw new Error('ERREUR indiscutable');
}
catch(e){
if( nbError < 1)
debug( '<b>Vrai ERREUR<\/b> ' +e.message);
else
debug( 'Inutile d\'insister...');
}
finally{
if( nbError < 1)
debug( 'Aller on n\'en parle plus...<br>');
else
debug( 'Il est <b>lourd<\/b> celui là !<br>');
}
}
</script>
</head>
<body>
<button onclick="fctErreur();">Test Erreur</button>
</body>
</html> |