blob: 58b8a14d6dc9d405bdb499a0587c2e85c9cdcb39 [file] [log] [blame]
Sadik Armagana97a0be2020-03-03 10:44:56 +00001//
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
11namespace armnnProfiling
12{
13
14/// Socket Connection Exception for profiling
15class SocketConnectionException : public std::exception
16{
17public:
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
45private:
46 std::string m_Message;
47 int m_Socket;
48 int m_ErrNo;
49};
50
51} // namespace armnnProfiling