Sadik Armagan | a97a0be | 2020-03-03 10:44:56 +0000 | [diff] [blame^] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #pragma once |
| 6 | |
| 7 | #include <sstream> |
| 8 | #include <stdexcept> |
| 9 | #include <string> |
| 10 | |
| 11 | namespace armnnProfiling |
| 12 | { |
| 13 | |
| 14 | /// Socket Connection Exception for profiling |
| 15 | class SocketConnectionException : public std::exception |
| 16 | { |
| 17 | public: |
| 18 | explicit SocketConnectionException(const std::string& message, int socket) |
| 19 | : m_Message(message), m_Socket(socket), m_ErrNo(-1) |
| 20 | {}; |
| 21 | |
| 22 | explicit SocketConnectionException(const std::string& message, int socket, int errNo) |
| 23 | : m_Message(message), m_Socket(socket), m_ErrNo(errNo) |
| 24 | {}; |
| 25 | |
| 26 | /// @return - Error message of SocketProfilingConnection |
| 27 | virtual const char* what() const noexcept override |
| 28 | { |
| 29 | return m_Message.c_str(); |
| 30 | } |
| 31 | |
| 32 | /// @return - Socket File Descriptor of SocketProfilingConnection |
| 33 | /// or '-1', an invalid file descriptor |
| 34 | int GetSocketFd() const noexcept |
| 35 | { |
| 36 | return m_Socket; |
| 37 | } |
| 38 | |
| 39 | /// @return - errno of SocketProfilingConnection |
| 40 | int GetErrorNo() const noexcept |
| 41 | { |
| 42 | return m_ErrNo; |
| 43 | } |
| 44 | |
| 45 | private: |
| 46 | std::string m_Message; |
| 47 | int m_Socket; |
| 48 | int m_ErrNo; |
| 49 | }; |
| 50 | |
| 51 | } // namespace armnnProfiling |