dfhack/library/Error.cpp

44 lines
1.2 KiB
C++

#include "Error.h"
#include "MiscUtils.h"
using namespace DFHack::Error;
2018-02-07 09:40:52 -07:00
inline std::string safe_str(const char *s)
{
return s ? s : "(NULL)";
}
NullPointer::NullPointer(const char *varname)
2018-02-07 09:40:52 -07:00
:All("NULL pointer: " + safe_str(varname)),
varname(varname)
{}
InvalidArgument::InvalidArgument(const char *expr)
2018-02-07 09:40:52 -07:00
:All("Invalid argument; expected: " + safe_str(expr)),
expr(expr)
{}
VTableMissing::VTableMissing(const char *name)
2018-02-07 09:40:52 -07:00
:All("Missing vtable address: " + safe_str(name)),
name(name)
{}
SymbolsXmlParse::SymbolsXmlParse(const char* desc, int id, int row, int col)
2018-02-07 09:40:52 -07:00
:AllSymbols(stl_sprintf("error %d: %s, at row %d col %d", id, desc, row, col)),
desc(safe_str(desc)), id(id), row(row), col(col)
{}
SymbolsXmlBadAttribute::SymbolsXmlBadAttribute(const char *attr)
2018-02-07 09:40:52 -07:00
:AllSymbols("attribute is either missing or invalid: " + safe_str(attr)),
attr(safe_str(attr))
{}
SymbolsXmlNoRoot::SymbolsXmlNoRoot()
:AllSymbols("no root element")
{}
SymbolsXmlUnderspecifiedEntry::SymbolsXmlUnderspecifiedEntry(const char *where)
2018-02-07 09:40:52 -07:00
:AllSymbols("Underspecified symbol file entry, each entry needs to set both the name attribute and have a value. parent: " + safe_str(where)),
where(safe_str(where))
{}