xtd 0.2.0
Loading...
Searching...
No Matches
exception.h
Go to the documentation of this file.
1
4#pragma once
6#include "core_export.h"
7#include "h_result.h"
8#include "object.h"
9#include "nullopt.h"
10#include "optional.h"
11#include "ptr.h"
12#include "string.h"
13#include <exception>
14#include <system_error>
15
17namespace xtd {
19 class system_exception;
21
28 class core_export_ exception : public object, public std::exception {
29 public:
31
36
38
52 template<typename exception_t>
53 exception(const xtd::optional<xtd::string>& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : exception(message, inner_exception.template memberwise_clone<exception_t>(), stack_frame, true) {}
55
57 exception(exception&&) = default;
58 exception(const exception&) = default;
59 exception& operator =(exception&&) = default;
60 exception& operator =(const exception&) = default;
62
64
68 virtual const xtd::string& help_link() const noexcept;
71 virtual void help_link(const xtd::string& value) noexcept;
72
75 virtual int32 h_result() const noexcept;
78 virtual void h_result(int32 value) noexcept;
79
82 virtual const std::error_code& error_code() const noexcept;
85 virtual void error_code(const std::error_code& value) noexcept;
86
89 virtual exception_ref inner_exception() const noexcept;
90
93 virtual const xtd::string& message() const noexcept;
94
98 virtual const xtd::string& source() const noexcept;
102 virtual void source(const xtd::string& value) noexcept;
103
106 virtual xtd::string stack_trace() const noexcept;
108
110
114 virtual const xtd::diagnostics::stack_frame& get_last_stack_frame() const noexcept;
117 xtd::string to_string() const noexcept override;
118
121 const char* what() const noexcept override;
123
125
129 static bool enable_stack_trace() noexcept;
132 static void enable_stack_trace(bool enable) noexcept;
134
135 private:
136 exception(const xtd::optional<xtd::string>& message, uptr<xtd::exception>&& inner_exception, const xtd::diagnostics::stack_frame& stack_frame, bool);
137 xtd::string stack_trace_to_string() const noexcept;
138
139 const xtd::string& get_name() const noexcept;
140
141 struct data;
142 ptr<data> data_;
143 static bool enable_stack_trace_;
144 };
145}
Represents text as a sequence of character units.
Definition basic_string.h:79
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.h:47
static stack_frame current(const xtd::source_location &value=xtd::source_location::current()) noexcept
Crates a new xtd::diagnostics::stack_frame object corresponding to the location of the call site.
Defines the base class for predefined exceptions in the xtd namespace.
Definition exception.h:28
xtd::optional< std::reference_wrapper< const xtd::exception > > exception_ref
Optional reference wrapper on std::exception.
Definition exception.h:34
exception(const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Create a new instance of class exception.
exception(const xtd::optional< xtd::string > &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Create a new instance of class exception.
exception(const xtd::optional< xtd::string > &message, const exception_t &inner_exception, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Create a new instance of class exception.
Definition exception.h:53
virtual const xtd::string & help_link() const noexcept
Gets a link to the help file associated with this exception.
Contains the HRESULT values used by xtd.
Definition h_result.h:94
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
Contains core_export_ keyword.
#define core_export_
Define shared library export.
Definition core_export.h:13
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.h:27
std::optional< type_t > optional
Represents the null_opt alias on std::nullopt_t.
Definition optional.h:181
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
std::unique_ptr< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.h:25
Contains xtd::h_result class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::nullopt valiue.
Contains xtd::object class.
Contains xtd::optional type.
Contains xtd::ptr type.
Contains xtd::diagnostics::stack_frame class.
Contains xtd::string alias.