Bonjour à tous,

J'aimerai faire ma gestion d'erreur autour des exceptions. Je possède une classe de conversion et voici son code:

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
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 
// Code d'une fonction dans ma classe de conversion
void CConverter::ToInt(const char* sIn, int& iOut)
{
	try
	{
		iOut = lexical_cast<int>(sIn);
	}
	catch(std::exception)
	{
		throw new CConvertException("const char*", "int&", sIn);
	}
}
 
// Code de la fonction appelante
try
{
	CConverter::Instance().ToInt(sString.c_str(), iValue);
}
catch(CConvertException ex)
{
	LogManager::Instance() << ex.What();
}
 
// Classe de CConvertException
#include "../../Exception/CException.h"
 
namespace kin
{
	namespace utils
	{
		namespace conversion
		{
			namespace exceptions
			{
				class CConvertException : public kin::utils::exception::CException
				{
				public:
					CConvertException(
						const std::string& sFromType,
						const std::string& sToType,
						const std::string& sValue,
						const std::string& sMessage = "Conversion impossible.");
				};
			};
		};
	};
};
 
// Classe CException
#include <exception>
#include <string>
#include <vector>
#include <map>
 
namespace kin
{
	namespace utils
	{
		namespace exception
		{
			class CException : public std::exception
			{
			public :
				CException(const std::string& sMessage, CException* oOriginException = NULL);
				CException* GetOriginException();
				const char* what() const throw();
 
			protected :
				std::string m_sMessage;
				void AddCause(const char* sCause);
				void AddParam(const char* sKey, const char*sValue);
 
			private:
				std::vector<const char*> m_oCauseVector;
				std::map<const char*, const char*> m_oParamMap;
				CException* m_oOriginException;
			};
		};
	};
};
Voilà, lors du "throw", ça me renvoi une exception non géré, alors que l'appelle de celle-ci est entouré d'un try/catch :s

Donc je ne comprends pas, CException dérive de std::exception, et CConvertException dérive de CException, le catch "attrape" bien les exception de type CConvertException...

Quelqu'un peut m'éclairer?

Merci beaucoup

A bientôt