xtd 0.2.0
exception.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "core_export.hpp"
7#include "h_result.hpp"
8#include "object.hpp"
9#include "nullopt.hpp"
10#include "optional.hpp"
11#include "ptr.hpp"
12#include "uptr.hpp"
13#include "string.hpp"
15#include <exception>
16#include <system_error>
17
19namespace xtd {
21 class system_exception;
23
30 class core_export_ exception : public object, public std::exception {
31 public:
33
38
40
54 template<class exception_t>
57
59 exception(exception&&) = default;
60 exception(const exception&) = default;
61 exception& operator =(exception&&) = default;
62 exception& operator =(const exception&) = default;
64
66
70 virtual const xtd::string& help_link() const noexcept;
73 virtual void help_link(const xtd::string& value) noexcept;
74
77 virtual int32 h_result() const noexcept;
80 virtual void h_result(int32 value) noexcept;
81
84 virtual const std::error_code& error_code() const noexcept;
87 virtual void error_code(const std::error_code& value) noexcept;
88
91 virtual exception_ref inner_exception() const noexcept;
92
95 virtual const xtd::string& message() const noexcept;
96
100 virtual const xtd::string& source() const noexcept;
104 virtual void source(const xtd::string& value) noexcept;
105
108 virtual xtd::string stack_trace() const noexcept;
110
112
116 virtual const xtd::diagnostics::stack_frame& get_last_stack_frame() const noexcept;
119 xtd::string to_string() const noexcept override;
120
123 const char* what() const noexcept override;
125
127
131 static bool enable_stack_trace() noexcept;
134 static void enable_stack_trace(bool enable) noexcept;
136
137 private:
138 exception(const xtd::optional<xtd::string>& message, uptr<xtd::exception>&& inner_exception, const xtd::diagnostics::stack_frame& stack_frame, bool);
139 xtd::string stack_trace_to_string() const noexcept;
140
141 const xtd::string& get_name() const noexcept;
142
143 struct data;
144 ptr<data> data_;
145 static bool enable_stack_trace_;
146 };
147}
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.hpp:48
static stack_frame current(const xtd::diagnostics::source_location &value=xtd::diagnostics::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.hpp:30
virtual const std::error_code & error_code() const noexcept
Gets error associate to the exception.
xtd::string to_string() const noexcept override
Returns a string that represents the current exception.
virtual const xtd::string & message() const noexcept
Gets message associate to the exception.
exception(const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Create a new instance of class exception.
virtual const xtd::string & source() const noexcept
Gets the name of the application or the object that causes the error.
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.
virtual const xtd::diagnostics::stack_frame & get_last_stack_frame() const noexcept
Gets the last stack frame where the exception occurred.
virtual int32 h_result() const noexcept
Gets HRESULT, a coded numerical value that is assigned to a specific exception.
const char * what() const noexcept override
Gets message associate to the exception.
virtual exception_ref inner_exception() const noexcept
Gets the exception instance that caused the current 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.hpp:55
virtual xtd::string stack_trace() const noexcept
Gets a string representation of the immediate frames on the call stack.
xtd::optional< xtd::ref< const xtd::exception > > exception_ref
Optional reference wrapper on std::exception.
Definition exception.hpp:36
virtual const xtd::string & help_link() const noexcept
Gets a link to the help file associated with this exception.
static bool enable_stack_trace() noexcept
Gets if the generation of the stack trace is enabled.
xtd::unique_ptr_object< object_t > memberwise_clone() const
Creates a shallow copy of the current object.
object()=default
Create a new instance of the ultimate base class object.
The exception that is thrown when a method call is invalid for the object's current state.
Definition system_exception.hpp:18
Contains core_export_ keyword.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
xtd::unique_ptr_object< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
std::optional< type_t > optional
Represents the optional alias on std::optional.
Definition optional.hpp:25
Contains xtd::h_result class.
Contains xtd::translator suffixes.
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
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.
Contains xtd::uptr type.