HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
Exception.h
Go to the documentation of this file.
1#pragma once
2#include "HephShared.h"
3#include "Event.h"
4#include <exception>
5#include <string>
6#include <vector>
7#include <memory>
8
15#define HEPH_EXCEPTION_DEFAULT_HANDLER &Heph::Exception::DefaultHandler
16
21#define HEPH_RAISE_EXCEPTION(pSender, ex) (ex).Raise((const void*)(pSender))
22
27#define HEPH_RAISE_AND_THROW_EXCEPTION(pSender, ex) { \
28 (ex).Raise((const void*)(pSender)); \
29 throw (ex); \
30 }
31
32namespace Heph
33{
39 class HEPH_API Exception : public std::exception
40 {
41 public:
46 static inline Event OnException = Event();
47
48 protected:
53 std::string method;
54
59 std::string message;
60
61 public:
64
71 Exception(const std::string& method, const std::string& message);
72
74 virtual ~Exception() = default;
75
76 virtual const char* what() const noexcept override;
77
82 virtual std::string GetName() const;
83
88 virtual const std::string& GetMethod() const;
89
94 virtual const std::string& GetMessage() const;
95
101 virtual void Raise(const void* pSender) const;
102
103 protected:
108 virtual void AddToExceptions() const;
109
110 public:
115 static std::shared_ptr<Exception> GetLastException() noexcept;
116
121 static std::vector<std::shared_ptr<Exception>>& GetExceptions() noexcept;
122
128 static void DefaultHandler(const EventParams& params);
129 };
130}
#define HEPH_API
Definition HephShared.h:132
class for managing callback functions.
Definition Event.h:25
stores exception information. Base class for exceptions.
Definition Exception.h:40
std::string message
Definition Exception.h:59
std::string method
Definition Exception.h:53
Exception(const std::string &method, const std::string &message)
virtual ~Exception()=default
stores the information required to handle an event.
Definition EventParams.h:16