Перейдя через некоторые ссылки на обработку исключений (1, 2, и 3), я знаю, что программы на С++ могут вообще что-то делать как исключения (int
, char*
, string
, exception
). Я знаю, что std::exception
- это базовый класс для стандартных исключений, создаваемых программой. Тем не менее, я пытаюсь создать блок try
... catch
как таковой:
try
{
MyFunc();
}
catch (certain exceptions)
{
// deal with the exception accordingly
}
catch (the rest of the exceptions)
{
// deal with these accordingly
}
while MyFunc()
содержит следующее:
void MyFunc()
{
...
if (certain condition is true) throw exception;
...
}
Проблема в том, что в этой части функции MyFunc
я не уверен, какой тип исключения я должен бросить. Чтобы сохранить код чистым, реализуя мой собственный класс исключений, я понятия не имею, что было бы хорошим способом реализовать такой класс исключений.