| 1 | // Copyright (C) Microsoft Corporation. All rights reserved. |
| 2 | #include <sstream> |
| 3 | #include "NetlinkParseException.h" |
| 4 | #include "NetlinkResponse.h" |
| 5 | #include "Utils.h" |
| 6 | |
| 7 | NetlinkParseException::NetlinkParseException(const NetlinkResponse& response, const std::string& reason, const std::source_location& source) : |
| 8 | RuntimeErrorWithSourceLocation(BuildMessage(response, reason), source) |
| 9 | { |
| 10 | } |
| 11 | |
| 12 | std::string NetlinkParseException::BuildMessage(const NetlinkResponse& response, const std::string& reason) |
| 13 | { |
| 14 | std::stringstream str; |
| 15 | str << reason << " Netlink response: "; |
| 16 | utils::FormatBinary(str, &*response.Begin(), response.End() - response.Begin()); |
| 17 | |
| 18 | return str.str(); |
| 19 | } |