mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-02 12:32:40 +02:00
fix .what methods on exceptions
This commit is contained in:
@@ -15,24 +15,24 @@
|
|||||||
|
|
||||||
struct ParseException: public std::exception {
|
struct ParseException: public std::exception {
|
||||||
enum ParseResult { OK = 0, Corrupt, WrongVersion, InvalidDimensions, InternalError, MissingElement };
|
enum ParseResult { OK = 0, Corrupt, WrongVersion, InvalidDimensions, InternalError, MissingElement };
|
||||||
String message;
|
ByteString message;
|
||||||
ParseResult result;
|
ParseResult result;
|
||||||
public:
|
public:
|
||||||
ParseException(ParseResult result, String message_): message(message_), result(result) {}
|
ParseException(ParseResult result, String message): message(message.ToUtf8()), result(result) {}
|
||||||
const char * what() const throw()
|
const char * what() const throw() override
|
||||||
{
|
{
|
||||||
return message.ToUtf8().c_str();
|
return message.c_str();
|
||||||
}
|
}
|
||||||
~ParseException() throw() {}
|
~ParseException() throw() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BuildException: public std::exception {
|
struct BuildException: public std::exception {
|
||||||
String message;
|
ByteString message;
|
||||||
public:
|
public:
|
||||||
BuildException(String message_): message(message_) {}
|
BuildException(String message): message(message.ToUtf8()) {}
|
||||||
const char * what() const throw()
|
const char * what() const throw() override
|
||||||
{
|
{
|
||||||
return message.ToUtf8().c_str();
|
return message.c_str();
|
||||||
}
|
}
|
||||||
~BuildException() throw() {}
|
~BuildException() throw() {}
|
||||||
};
|
};
|
||||||
|
@@ -10,12 +10,12 @@
|
|||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
struct RichTextParseException: public std::exception {
|
struct RichTextParseException: public std::exception {
|
||||||
String message;
|
ByteString message;
|
||||||
public:
|
public:
|
||||||
RichTextParseException(String message_ = String("Parse error")): message(message_) {}
|
RichTextParseException(String message = String("Parse error")): message(message.ToUtf8()) {}
|
||||||
const char * what() const throw()
|
const char * what() const throw() override
|
||||||
{
|
{
|
||||||
return message.ToUtf8().c_str();
|
return message.c_str();
|
||||||
}
|
}
|
||||||
~RichTextParseException() throw() {};
|
~RichTextParseException() throw() {};
|
||||||
};
|
};
|
||||||
|
@@ -27,7 +27,11 @@ SearchView::SearchView():
|
|||||||
nextButton = new ui::Button(ui::Point(WINDOWW-52, WINDOWH-18), ui::Point(50, 16), String("Next ") + 0xE015);
|
nextButton = new ui::Button(ui::Point(WINDOWW-52, WINDOWH-18), ui::Point(50, 16), String("Next ") + 0xE015);
|
||||||
previousButton = new ui::Button(ui::Point(2, WINDOWH-18), ui::Point(50, 16), 0xE016 + String(" Prev"));
|
previousButton = new ui::Button(ui::Point(2, WINDOWH-18), ui::Point(50, 16), 0xE016 + String(" Prev"));
|
||||||
tagsLabel = new ui::Label(ui::Point(270, WINDOWH-18), ui::Point(WINDOWW-540, 16), "\boPopular Tags:");
|
tagsLabel = new ui::Label(ui::Point(270, WINDOWH-18), ui::Point(WINDOWW-540, 16), "\boPopular Tags:");
|
||||||
motdLabel = new ui::RichLabel(ui::Point(51, WINDOWH-18), ui::Point(WINDOWW-102, 16), Client::Ref().GetMessageOfTheDay());
|
try
|
||||||
|
{
|
||||||
|
motdLabel = new ui::RichLabel(ui::Point(51, WINDOWH-18), ui::Point(WINDOWW-102, 16), Client::Ref().GetMessageOfTheDay());
|
||||||
|
}
|
||||||
|
catch (std::exception e) { }
|
||||||
|
|
||||||
class PageNumAction : public ui::TextboxAction
|
class PageNumAction : public ui::TextboxAction
|
||||||
{
|
{
|
||||||
@@ -253,7 +257,18 @@ SearchView::SearchView():
|
|||||||
|
|
||||||
void SearchView::NotifyMessageOfTheDay(Client * sender)
|
void SearchView::NotifyMessageOfTheDay(Client * sender)
|
||||||
{
|
{
|
||||||
motdLabel->SetText(sender->GetMessageOfTheDay());
|
if (motdLabel)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
motdLabel->SetText(sender->GetMessageOfTheDay());
|
||||||
|
}
|
||||||
|
catch (std::exception e)
|
||||||
|
{
|
||||||
|
motdLabel = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchView::doSearch()
|
void SearchView::doSearch()
|
||||||
@@ -467,8 +482,11 @@ void SearchView::NotifyTagListChanged(SearchModel * sender)
|
|||||||
|
|
||||||
vector<pair<ByteString, int> > tags = sender->GetTagList();
|
vector<pair<ByteString, int> > tags = sender->GetTagList();
|
||||||
|
|
||||||
RemoveComponent(motdLabel);
|
if (motdLabel)
|
||||||
motdLabel->SetParentWindow(NULL);
|
{
|
||||||
|
RemoveComponent(motdLabel);
|
||||||
|
motdLabel->SetParentWindow(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
RemoveComponent(tagsLabel);
|
RemoveComponent(tagsLabel);
|
||||||
tagsLabel->SetParentWindow(NULL);
|
tagsLabel->SetParentWindow(NULL);
|
||||||
@@ -499,8 +517,11 @@ void SearchView::NotifyTagListChanged(SearchModel * sender)
|
|||||||
AddComponent(tagsLabel);
|
AddComponent(tagsLabel);
|
||||||
tagsLabel->Position.Y = tagYOffset-16;
|
tagsLabel->Position.Y = tagYOffset-16;
|
||||||
|
|
||||||
AddComponent(motdLabel);
|
if (motdLabel)
|
||||||
motdLabel->Position.Y = tagYOffset-30;
|
{
|
||||||
|
AddComponent(motdLabel);
|
||||||
|
motdLabel->Position.Y = tagYOffset-30;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TagAction: public ui::ButtonAction
|
class TagAction: public ui::ButtonAction
|
||||||
|
@@ -35,7 +35,7 @@ private:
|
|||||||
ui::Label * pageLabel;
|
ui::Label * pageLabel;
|
||||||
ui::Label * pageCountLabel;
|
ui::Label * pageCountLabel;
|
||||||
ui::Label * tagsLabel;
|
ui::Label * tagsLabel;
|
||||||
ui::RichLabel * motdLabel;
|
ui::RichLabel * motdLabel = nullptr;
|
||||||
ui::Button * sortButton;
|
ui::Button * sortButton;
|
||||||
ui::Button * ownButton;
|
ui::Button * ownButton;
|
||||||
ui::Spinner * loadingSpinner;
|
ui::Spinner * loadingSpinner;
|
||||||
|
@@ -4,11 +4,11 @@
|
|||||||
#include "common/String.h"
|
#include "common/String.h"
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
class TagsModelException {
|
class TagsModelException : public std::exception {
|
||||||
String message;
|
ByteString message;
|
||||||
public:
|
public:
|
||||||
TagsModelException(String message_): message(message_) {};
|
TagsModelException(String message): message(message.ToUtf8()) {};
|
||||||
const char * what() const throw() { return message.ToUtf8().c_str(); };
|
const char * what() const throw() override { return message.c_str(); };
|
||||||
~TagsModelException() throw() {};
|
~TagsModelException() throw() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user