Bonjour à tous,
Voilà, j'ai lu le tuto suivant: http://guillaume-affringue.developpe...?page=sommaire

Mais j'ai un peu modifier ma class MyPHPException.
Lorsque je l'utilise sur une fonction de php, tout fonctionne correctement.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
<?php
require_once('erreur.class.php5');
try {
    mysql('serveurBidon', 'LoginBidon', 'MDPBidon');
}
catch (MyPHPException $myPHPException) {
    echo $myPHPException->showError();
}
?>
L'exception fonctionne.

Si maintenant je fait:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
require_once('erreur.class.php5');
function test($param1){
	if ($param1 != 2){
			throw new Exception('test');
	}
	else { 
		return print('C\'est 2!');
	}
}
 
try {
    test(1);
}
catch (MyPHPException $myPHPException) {
    echo $myPHPException->showError();
}
?>
J'ai le message d'erreur suivant:
Fatal error: Uncaught exception 'Exception' with message 'test' in /home.10/mendrock/www/new/class/class/erreur.php5:5 Stack trace: #0 /home.10/mendrock/www/new/class/class/erreur.php5(13): test(3) #1 {main} thrown in /home.10/mendrock/www/new/class/class/erreur.php5 on line 5
Pouvez vous m'aidez?
Avez-vous besoin de la classe "myPHPException" ?

Merci d'avance.