Catch JSON errors.

This commit is contained in:
tastytea 2019-12-28 09:52:39 +01:00
parent bad3059092
commit 2a0fd3d6e4
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 10 additions and 3 deletions

View File

@ -2,7 +2,7 @@
:doctype: manpage
:Author: tastytea
:Email: tastytea@tastytea.de
:Date: 2019-12-25
:Date: 2019-12-28
:Revision: 0.0.0
:man source: mastorss
:man manual: General Commands Manual
@ -157,15 +157,16 @@ proxy support yet, sorry.
== ERROR CODES
[cols=">,<"]
|===========================================================
|===============================================================================
| Code | Explanation
| 1 | No profile specified.
| 2 | Network error.
| 3 | File error.
| 4 | Mastodon API error.
| 5 | JSON error, most likely the file is wrongly formatted.
| 9 | Unknown error.
|===========================================================
|===============================================================================
== DEBUGGING

View File

@ -34,6 +34,7 @@ constexpr int noprofile = 1;
constexpr int network = 2;
constexpr int file = 3;
constexpr int mastodon = 4;
constexpr int json = 5;
constexpr int unknown = 9;
} // namespace error
@ -134,6 +135,11 @@ int main(int argc, char *argv[])
cerr << e.what() << '\n';
return error::network;
}
catch (const Json::RuntimeError &e)
{
cerr << "JSON error:\n" << e.what() << '\n';
return error::json;
}
catch (const runtime_error &e)
{
cerr << e.what() << '\n';