mavtables  0.2.1
MAVLink router and firewall.
PartialSendError.cpp
Go to the documentation of this file.
1 // MAVLink router and firewall.
2 // Copyright (C) 2018 Michael R. Shannon <mrshannon.aerospace@gmail.com>
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 
18 #include <string>
19 #include <utility>
20 
21 #include "PartialSendError.hpp"
22 
23 
24 /** Construct a \ref PartialSendError.
25  *
26  * \param bytes_sent Number of bytes that were sent.
27  * \param total_bytes Total number of bytes in the packet.
28  */
30  unsigned long bytes_sent, unsigned long total_bytes)
31 {
32  message_ = "Could only write " + std::to_string(bytes_sent) +
33  " of " + std::to_string(total_bytes) + " bytes.";
34 }
35 
36 
37 /** Return error message string.
38  *
39  * \returns Error message string containing sent to total bytes ratio.
40  */
41 const char *PartialSendError::what() const noexcept
42 {
43  return message_.c_str();
44 }
const char * what() const noexcept
PartialSendError(unsigned long bytes_sent, unsigned long total_bytes)