Made Aegilib::Exception derive from std::exception.

Originally committed to SVN as r2039.
This commit is contained in:
Rodrigo Braz Monteiro 2008-03-13 07:28:30 +00:00
parent dff23e8cd3
commit bcb87d1ebd
3 changed files with 9 additions and 5 deletions

View File

@ -36,11 +36,12 @@
#pragma once
#include "aegistring.h"
#include <exception>
namespace Aegilib {
// Exception class
class Exception {
class Exception : public std::exception {
public:
enum ExceptionList {
Unknown,
@ -55,10 +56,11 @@ namespace Aegilib {
Exception(ExceptionList code);
String GetMessage();
String GetMessage() const { return GetMessage(code); }
int GetCode();
private:
static String GetMessage(int code);
ExceptionList code;
};

View File

@ -40,6 +40,7 @@ using namespace Aegilib;
///////////////
// Constructor
Exception::Exception(ExceptionList _code)
: std::exception(GetMessage(_code).mb_str(wxConvLocal))
{
code = _code;
}
@ -47,7 +48,7 @@ Exception::Exception(ExceptionList _code)
//////////////////////
// Get message string
String Exception::GetMessage()
String Exception::GetMessage(int code)
{
switch (code) {
case Unknown: return L"Unknown.";

View File

@ -60,6 +60,7 @@ int main () {
// Modify subtitles
cout << "Modifying file...";
// TODO
cout << "Done.\n";
// Save subtitles
@ -68,7 +69,7 @@ int main () {
cout << "Done.\n";
}
catch (Exception &e) {
cout << "\n\nException: " << e.GetMessage().mb_str(wxConvUTF8) << endl << endl;
catch (std::exception &e) {
cout << "\n\nException: " << e.what() << endl << endl;
}
}