diff options
Diffstat (limited to 'src/user.cpp')
-rw-r--r-- | src/user.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/user.cpp b/src/user.cpp index d2fa592..8109123 100644 --- a/src/user.cpp +++ b/src/user.cpp | |||
@@ -1,24 +1,25 @@ | |||
1 | #include "user.h" | 1 | #include "user.h" |
2 | #include <json.hpp> | 2 | #include <json.hpp> |
3 | #include "codes.h" | 3 | #include "codes.h" |
4 | #include "client.h" | ||
5 | 4 | ||
6 | namespace twitter { | 5 | namespace twitter { |
7 | 6 | ||
8 | user::user(std::string data) try | 7 | user::user(std::string data) |
9 | : _valid(true) | ||
10 | { | 8 | { |
11 | auto json = nlohmann::json::parse(data); | 9 | try |
12 | _id = json["id"].get<user_id>(); | 10 | { |
13 | _screen_name = json["screen_name"].get<std::string>(); | 11 | auto json = nlohmann::json::parse(data); |
14 | _name = json["name"].get<std::string>(); | 12 | _id = json["id"].get<user_id>(); |
15 | _protected = json["protected"].get<bool>(); | 13 | _screen_name = json["screen_name"].get<std::string>(); |
16 | } catch (const std::invalid_argument& error) | 14 | _name = json["name"].get<std::string>(); |
17 | { | 15 | _protected = json["protected"].get<bool>(); |
18 | std::throw_with_nested(malformed_object("user", data)); | 16 | } catch (const std::invalid_argument& error) |
19 | } catch (const std::domain_error& error) | 17 | { |
20 | { | 18 | std::throw_with_nested(malformed_object("user", data)); |
21 | std::throw_with_nested(malformed_object("user", data)); | 19 | } catch (const std::domain_error& error) |
20 | { | ||
21 | std::throw_with_nested(malformed_object("user", data)); | ||
22 | } | ||
22 | } | 23 | } |
23 | 24 | ||
24 | }; | 25 | } |