blob: abdc0dc02588d832de4a7b7131e5a20ca4a34916 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
//
// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once
#include <stdexcept>
#include <string>
#include <sstream>
namespace arm
{
namespace pipe
{
struct Location
{
const char* m_Function;
const char* m_File;
unsigned int m_Line;
Location(const char* func,
const char* file,
unsigned int line)
: m_Function{func}
, m_File{file}
, m_Line{line}
{
}
std::string AsString() const
{
std::stringstream ss;
ss << " at function " << m_Function
<< " [" << m_File << ':' << m_Line << "]";
return ss.str();
}
std::string FileLine() const
{
std::stringstream ss;
ss << " [" << m_File << ':' << m_Line << "]";
return ss.str();
}
};
/// General Exception class for Profiling code
class ProfilingException : public std::exception
{
public:
explicit ProfilingException(const std::string& message) : m_Message(message) {};
explicit ProfilingException(const std::string& message,
const Location& location) : m_Message(message + location.AsString()) {};
/// @return - Error message of ProfilingException
virtual const char *what() const noexcept override
{
return m_Message.c_str();
}
private:
std::string m_Message;
};
class TimeoutException : public ProfilingException
{
public:
using ProfilingException::ProfilingException;
};
class InvalidArgumentException : public ProfilingException
{
public:
using ProfilingException::ProfilingException;
};
} // namespace pipe
} // namespace arm
#define LOCATION() arm::pipe::Location(__func__, __FILE__, __LINE__)
|