From bbfe603e5ae42317a2b67d713d00882bea341c88 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Mon, 20 Jul 2020 16:57:44 +0100 Subject: IVGCVSW-5166 Pull out the common and server side code into standalone libraries Change-Id: I180f84c493a9b2be4b93b25d312ebdd9e71b1735 Signed-off-by: Jim Flynn --- profiling/common/include/ProfilingException.hpp | 63 +++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 5 deletions(-) (limited to 'profiling/common/include/ProfilingException.hpp') diff --git a/profiling/common/include/ProfilingException.hpp b/profiling/common/include/ProfilingException.hpp index 532c2d49f7..abdc0dc025 100644 --- a/profiling/common/include/ProfilingException.hpp +++ b/profiling/common/include/ProfilingException.hpp @@ -1,29 +1,82 @@ // -// Copyright © 2020 Arm Ltd. All rights reserved. +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // #pragma once #include #include +#include -namespace armnnProfiling +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 + virtual const char *what() const noexcept override { - return m_Message.c_str(); + return m_Message.c_str(); } private: std::string m_Message; }; -} // namespace armnnProfiling +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__) -- cgit v1.2.1