• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
7 #include <sstream>
8 #include <stdexcept>
9 #include <string>
10 
11 #include "NetworkSockets.hpp"
12 
13 namespace arm
14 {
15 
16 namespace pipe
17 {
18 
19 /// Socket Connection Exception for profiling
20 class SocketConnectionException : public std::exception
21 {
22 public:
SocketConnectionException(const std::string & message,arm::pipe::Socket socket)23     explicit SocketConnectionException(const std::string &message, arm::pipe::Socket socket)
24         : m_Message(message), m_Socket(socket), m_ErrNo(-1) {};
25 
SocketConnectionException(const std::string & message,arm::pipe::Socket socket,int errNo)26     explicit SocketConnectionException(const std::string &message, arm::pipe::Socket socket, int errNo)
27         : m_Message(message), m_Socket(socket), m_ErrNo(errNo) {};
28 
29     /// @return - Error message of  SocketProfilingConnection
what() const30     virtual const char *what() const noexcept override
31     {
32         return m_Message.c_str();
33     }
34 
35     /// @return - Socket File Descriptor of SocketProfilingConnection
36     ///           or '-1', an invalid file descriptor
GetSocketFd() const37     arm::pipe::Socket GetSocketFd() const noexcept
38     {
39         return m_Socket;
40     }
41 
42     /// @return - errno of SocketProfilingConnection
GetErrorNo() const43     int GetErrorNo() const noexcept
44     {
45         return m_ErrNo;
46     }
47 
48 private:
49     std::string m_Message;
50     arm::pipe::Socket m_Socket;
51     int m_ErrNo;
52 };
53 } // namespace pipe
54 } // namespace arm
55