This commit is contained in:
parent
71783b2638
commit
7267981c37
|
@ -165,6 +165,7 @@ SOCKS proxy support yet, sorry.
|
|||
| 3 | File error.
|
||||
| 4 | Mastodon API error.
|
||||
| 5 | JSON error, most likely the file is wrongly formatted.
|
||||
| 6 | Feed parse error. Usually the type of feed could not be detected.
|
||||
| 9 | Unknown error.
|
||||
|===============================================================================
|
||||
|
||||
|
|
|
@ -141,6 +141,8 @@ void Document::parse()
|
|||
BOOST_LOG_TRIVIAL(debug) << "RSS detected.";
|
||||
parse_rss(tree);
|
||||
}
|
||||
|
||||
ParseException{"Could not detect type of feed."};
|
||||
}
|
||||
|
||||
void Document::parse_rss(const pt::ptree &tree)
|
||||
|
|
|
@ -63,4 +63,13 @@ const char *FileException::what() const noexcept
|
|||
{
|
||||
return _message.c_str();
|
||||
}
|
||||
|
||||
ParseException::ParseException(string message)
|
||||
: _message{move(message)}
|
||||
{}
|
||||
|
||||
const char *ParseException::what() const noexcept
|
||||
{
|
||||
return _message.c_str();
|
||||
}
|
||||
} // namespace mastorss
|
||||
|
|
|
@ -68,6 +68,18 @@ public:
|
|||
[[nodiscard]]
|
||||
const char *what() const noexcept override;
|
||||
|
||||
private:
|
||||
const string _message;
|
||||
};
|
||||
|
||||
class ParseException : public exception
|
||||
{
|
||||
public:
|
||||
explicit ParseException(string message);
|
||||
|
||||
[[nodiscard]]
|
||||
const char *what() const noexcept override;
|
||||
|
||||
private:
|
||||
const string _message;
|
||||
};
|
||||
|
|
|
@ -28,6 +28,7 @@ constexpr int network = 2;
|
|||
constexpr int file = 3;
|
||||
constexpr int mastodon = 4;
|
||||
constexpr int json = 5;
|
||||
constexpr int parse = 6;
|
||||
constexpr int unknown = 9;
|
||||
} // namespace error
|
||||
|
||||
|
@ -142,6 +143,11 @@ int main(int argc, char *argv[])
|
|||
cerr << "JSON error:\n" << e.what() << '\n';
|
||||
return error::json;
|
||||
}
|
||||
catch (const ParseException &e)
|
||||
{
|
||||
cerr << e.what() << '\n';
|
||||
return error::parse;
|
||||
}
|
||||
catch (const runtime_error &e)
|
||||
{
|
||||
cerr << e.what() << '\n';
|
||||
|
|
Loading…
Reference in New Issue
Block a user