blob: 42b8d9d67e3f0401f213dffaf581ed81f5f645fa [file] [log] [blame]
Laurent Carlier749294b2020-06-01 09:03:17 +01001//
Jim Flynnbbfe6032020-07-20 16:57:44 +01002// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
Sadik Armagana97a0be2020-03-03 10:44:56 +00003// SPDX-License-Identifier: MIT
4//
5#pragma once
6
7#include <sstream>
8#include <stdexcept>
9#include <string>
10
Rob Hughesb98032f2020-04-24 11:41:34 +010011#include "NetworkSockets.hpp"
12
Jim Flynnbbfe6032020-07-20 16:57:44 +010013namespace arm
14{
15
16namespace pipe
Sadik Armagana97a0be2020-03-03 10:44:56 +000017{
18
19/// Socket Connection Exception for profiling
20class SocketConnectionException : public std::exception
21{
22public:
Jim Flynnbbfe6032020-07-20 16:57:44 +010023 explicit SocketConnectionException(const std::string &message, arm::pipe::Socket socket)
24 : m_Message(message), m_Socket(socket), m_ErrNo(-1) {};
Sadik Armagana97a0be2020-03-03 10:44:56 +000025
Jim Flynnbbfe6032020-07-20 16:57:44 +010026 explicit SocketConnectionException(const std::string &message, arm::pipe::Socket socket, int errNo)
27 : m_Message(message), m_Socket(socket), m_ErrNo(errNo) {};
Sadik Armagana97a0be2020-03-03 10:44:56 +000028
29 /// @return - Error message of SocketProfilingConnection
Jim Flynnbbfe6032020-07-20 16:57:44 +010030 virtual const char *what() const noexcept override
Sadik Armagana97a0be2020-03-03 10:44:56 +000031 {
32 return m_Message.c_str();
33 }
34
35 /// @return - Socket File Descriptor of SocketProfilingConnection
36 /// or '-1', an invalid file descriptor
Jim Flynnbbfe6032020-07-20 16:57:44 +010037 arm::pipe::Socket GetSocketFd() const noexcept
Sadik Armagana97a0be2020-03-03 10:44:56 +000038 {
39 return m_Socket;
40 }
41
42 /// @return - errno of SocketProfilingConnection
43 int GetErrorNo() const noexcept
44 {
45 return m_ErrNo;
46 }
47
48private:
49 std::string m_Message;
Jim Flynnbbfe6032020-07-20 16:57:44 +010050 arm::pipe::Socket m_Socket;
Sadik Armagana97a0be2020-03-03 10:44:56 +000051 int m_ErrNo;
52};
Jim Flynnbbfe6032020-07-20 16:57:44 +010053} // namespace pipe
54} // namespace arm