Skip to content

Commit

Permalink
Revue exception
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Sep 28, 2024
1 parent ed031d0 commit e2672a7
Show file tree
Hide file tree
Showing 15 changed files with 145 additions and 307 deletions.
2 changes: 1 addition & 1 deletion src/xtd.core/include/xtd/access_violation_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace xtd {
/// @param inner_exception The exception that is the cause of the current exception.
/// @param information (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
template<typename exception_t>
access_violation_exception(const std::optional<xtd::string>& message, const std::optional<exception_t>& inner_exception, const xtd::diagnostics::stack_frame& info = xtd::diagnostics::stack_frame::empty()) : system_exception(message, inner_exception, info) {h_result(xtd::h_results::E_POINTER);}
access_violation_exception(const std::optional<xtd::string>& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& info = xtd::diagnostics::stack_frame::empty()) : system_exception(message, inner_exception, info) {h_result(xtd::h_results::E_POINTER);}

/// @brief Create a new instance of class access_violation_exception
/// @param message Message string associate to the exception.
Expand Down
58 changes: 2 additions & 56 deletions src/xtd.core/include/xtd/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,61 +49,7 @@ namespace xtd {
/// @param inner_exception The exception that is the cause of the current exception.
/// @param stack_frame (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
template<typename exception_t>
exception(const std::optional<xtd::string>& message, const std::optional<exception_t>& inner_exception, const xtd::diagnostics::stack_frame& info = xtd::diagnostics::stack_frame::empty()) : exception(message, inner_exception.has_value() ? inner_exception.value().template memberwise_clone<exception_t>() : nullptr, info) {}

/// @brief Create a new instance of class exception
/// @param message Message string associate to the exception.
/// @param error Error code associate to the exception.
/// @param stack_frame (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
/// @deprecated Use xtd::exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_framee) and manually set the property xtd::exception::error_code - Will be removed in version 0.4.0
exception(const xtd::string& message, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty());
/// @brief Create a new instance of class exception
/// @param message Message string associate to the exception.
/// @param help_link Help link string associate to the exception.
/// @param stack_frame (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
/// @deprecated Use xtd::exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_framee) and manually set the property xtd::exception::help_link - Will be removed in version 0.4.0
exception(const xtd::string& message, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty());
/// @brief Create a new instance of class exception
/// @param message Message string associate to the exception.
/// @param error Error code associate to the exception.
/// @param help_link Help link string associate to the exception.
/// @param stack_frame (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
/// @deprecated Use xtd::exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_framee) and manually set the properties xtd::exception::error_code and xtd::exception::help_link - Will be removed in version 0.4.0
exception(const xtd::string& message, const std::error_code& error, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty());
/// @brief Create a new instance of class exception
/// @param inner_exception The exception that is the cause of the current exception.
/// @param stack_frame (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
/// @remarks Message is set with the default message associate to the exception.
/// @deprecated Use xtd::exception (const xtd::string& message, const std::optional<exception_t>& inner_exception, const xtd::diagnostics::stack_frame& stack_framee) - Will be removed in version 0.4.0
explicit exception(const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty());
/// @brief Create a new instance of class exception
/// @param message Message string associate to the exception.
/// @param inner_exception The exception that is the cause of the current exception.
/// @param stack_frame (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
/// @deprecated Use xtd::exception (const xtd::string& message, const std::optional<exception_t>& inner_exception, const xtd::diagnostics::stack_frame& stack_framee) - Will be removed in version 0.4.0
exception(const xtd::string& message, const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty());
/// @brief Create a new instance of class exception
/// @param message Message string associate to the exception.
/// @param inner_exception The exception that is the cause of the current exception.
/// @param error Error code associate to the exception.
/// @param stack_frame (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
/// @deprecated Use xtd::exception (const xtd::string& message, const std::optional<exception_t>& inner_exception, const xtd::diagnostics::stack_frame& stack_framee) and manually set the property xtd::exception::error_code - Will be removed in version 0.4.0
exception(const xtd::string& message, const std::exception& inner_exception, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty());
/// @brief Create a new instance of class exception
/// @param message Message string associate to the exception.
/// @param inner_exception The exception that is the cause of the current exception.
/// @param help_link Help link string associate to the exception.
/// @param stack_frame (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
/// @deprecated Use xtd::exception (const xtd::string& message, const std::optional<exception_t>& inner_exception, const xtd::diagnostics::stack_frame& stack_framee) and manually set the property xtd::exception::help_link - Will be removed in version 0.4.0
exception(const xtd::string& message, const std::exception& inner_exception, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty());
/// @brief Create a new instance of class exception
/// @param message Message string associate to the exception.
/// @param inner_exception The exception that is the cause of the current exception.
/// @param error Error code associate to the exception.
/// @param help_link Help link string associate to the exception.
/// @param stack_frame (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
/// @deprecated Use xtd::exception (const xtd::string& message, const std::optional<exception_t>& inner_exception, const xtd::diagnostics::stack_frame& stack_framee) and manually set the properties xtd::exception::error_code and xtd::exception::help_link - Will be removed in version 0.4.0
exception(const xtd::string& message, const std::exception& inner_exception, const std::error_code& error, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty());
exception(const std::optional<xtd::string>& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::empty()) : exception(message, inner_exception.template memberwise_clone<exception_t>(), stack_frame, true) {}
/// @}

/// @cond
Expand Down Expand Up @@ -206,7 +152,7 @@ namespace xtd {
/// @}

private:
exception(const std::optional<xtd::string>& message, uptr<xtd::exception>&& inner_exception, const xtd::diagnostics::stack_frame& information);
exception(const std::optional<xtd::string>& message, uptr<xtd::exception>&& inner_exception, const xtd::diagnostics::stack_frame& information, bool);
xtd::string stack_trace_to_string() const noexcept;
const xtd::string& get_name() const noexcept;

Expand Down
14 changes: 12 additions & 2 deletions src/xtd.core/include/xtd/h_results_category.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@

/// @brief The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
namespace xtd {
/// @brief Contains the HRESULT values used by xtd.
/// @brief Obtains a reference to the static error category object for h_result errors. The object is required to override the virtual function error_category::name() to return a pointer to the string "h_results_category". It is used to identify error conditions that correspond to the xtd::h_results error codes.
/// @return A reference to the static object of unspecified runtime type, derived from [std::error_category](https://en.cppreference.com/w/cpp/error/error_category).
/// @par Namespace
/// xtd
/// @par Library
/// xtd.core
/// @ingroup xtd_core exceptions
/// @remarks For more information, see Winerror.h from Micorosft's Win32 API.
const std::error_category& h_results_category() noexcept;

/// @brief Creates error code value for xtd::h_results `h_result`.
/// @param h_result xtd::h_results error code to create error code for.
/// @return Error code corresponding to `h_result`.
/// @par Namespace
/// xtd
/// @par Library
/// xtd.core
/// @ingroup xtd_core exceptions
std::error_code make_error_code(int h_result) noexcept;
}
5 changes: 4 additions & 1 deletion src/xtd.core/include/xtd/system_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,25 @@ namespace xtd {
/// @param inner_exception The exception that is the cause of the current exception.
/// @param information (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
template<typename exception_t>
system_exception(const std::optional<xtd::string>& message, const std::optional<exception_t>& inner_exception, const xtd::diagnostics::stack_frame& info = xtd::diagnostics::stack_frame::empty()) : exception(message, inner_exception, info) {h_result(xtd::h_results::COR_E_SYSTEM);}
system_exception(const std::optional<xtd::string>& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& info = xtd::diagnostics::stack_frame::empty()) : exception(message, inner_exception, info) {error_code(make_error_code(h_results::COR_E_SYSTEM));}

/// @brief Create a new instance of class system_exception
/// @param message Message string associate to the exception.
/// @param error Error code associate to the exception.
/// @param information (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
/// @deprecated Use xtd::system_exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::error_code - Will be removed in version 0.4.0
explicit system_exception(const xtd::string& message, const std::error_code& error, const xtd::diagnostics::stack_frame& info = xtd::diagnostics::stack_frame::empty());
/// @brief Create a new instance of class system_exception
/// @param message Message string associate to the exception.
/// @param help_link Help link string associate to the exception.
/// @param information (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
/// @deprecated Use xtd::system_exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::help_link - Will be removed in version 0.4.0
explicit system_exception(const xtd::string& message, const xtd::string& help_link, const xtd::diagnostics::stack_frame& info = xtd::diagnostics::stack_frame::empty());
/// @brief Create a new instance of class system_exception
/// @param message Message string associate to the exception.
/// @param error Error code associate to the exception.
/// @param help_link Help link string associate to the exception.
/// @deprecated Use xtd::system_exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame) and manually set the properties xtd::exception::error_code and xtd::exception::help_link - Will be removed in version 0.4.0
explicit system_exception(const xtd::string& message, const std::error_code& error, const xtd::string& help_link, const xtd::diagnostics::stack_frame& info = xtd::diagnostics::stack_frame::empty());
/// @brief Create a new instance of class system_exception
/// @param inner_exception The exception that is the cause of the current exception.
Expand Down
2 changes: 1 addition & 1 deletion src/xtd.core/include/xtd/time_zone_not_found_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace xtd {
/// @param message Message string associate to the exception.
/// @param help_link Help link string associate to the exception.
/// @param information (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
explicit time_zone_not_found_exception(const xtd::string& message, const std::string& help_link, const xtd::diagnostics::stack_frame& info = xtd::diagnostics::stack_frame::empty()) : system_exception(message, help_link, info) {}
explicit time_zone_not_found_exception(const xtd::string& message, const xtd::string& help_link, const xtd::diagnostics::stack_frame& info = xtd::diagnostics::stack_frame::empty()) : system_exception(message, help_link, info) {}
/// @brief Create a new instance of class time_zone_not_found_exception
/// @param message Message string associate to the exception.
/// @param error Error code associate to the exception.
Expand Down
2 changes: 1 addition & 1 deletion src/xtd.core/include/xtd/timeout_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace xtd {
/// @param message Message string associate to the exception.
/// @param help_link Help link string associate to the exception.
/// @param information (optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically #current_stack_frame_.
explicit timeout_exception(const xtd::string& message, const std::string& help_link, const xtd::diagnostics::stack_frame& info = xtd::diagnostics::stack_frame::empty()) : system_exception(message, help_link, info) {}
explicit timeout_exception(const xtd::string& message, const xtd::string& help_link, const xtd::diagnostics::stack_frame& info = xtd::diagnostics::stack_frame::empty()) : system_exception(message, help_link, info) {}
/// @brief Create a new instance of class timeout_exception
/// @param message Message string associate to the exception.
/// @param error Error code associate to the exception.
Expand Down
Loading

0 comments on commit e2672a7

Please sign in to comment.