Skip to content

Commit

Permalink
Review xtd::io::file_load_exception
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Nov 2, 2024
1 parent 54b0add commit 7dd8e78
Show file tree
Hide file tree
Showing 4 changed files with 335 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/xtd.core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,7 @@ add_sources(
src/xtd/io/directory_not_found_exception.cpp
src/xtd/io/file.cpp
src/xtd/io/file_info.cpp
src/xtd/io/file_load_exception.cpp
src/xtd/io/file_not_found_exception.cpp
src/xtd/io/file_system_info.cpp
src/xtd/io/drive_info.cpp
Expand Down
68 changes: 44 additions & 24 deletions src/xtd.core/include/xtd/io/file_load_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,67 +32,87 @@ namespace xtd {
/// @name Public Constructors

/// @{
/// @brief Create a new instance of class file_load_exception
/// @brief Create a new instance of class xtd::io::file_load_exception
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
/// @remarks Message is set with the default message associate to the exception.
explicit file_load_exception(const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(default_message(), stack_frame) {}
/// @brief Create a new instance of class file_load_exception
explicit file_load_exception(const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::file_load_exception
/// @param message Message string associate to the exception.
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit file_load_exception(const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, stack_frame) {}
/// @brief Create a new instance of class file_load_exception
explicit file_load_exception(const xtd::optional<xtd::string>& message, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::file_load_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 stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
template<typename exception_t>
file_load_exception(const xtd::optional<xtd::string>& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, inner_exception, stack_frame) {error_code(h_result::make_error_code(h_result::COR_E_FILELOAD));}

/// @brief Create a new instance of class xtd::io::file_load_exception
/// @param message Message string associate to the exception.
/// @param error Error code associate to the exception.
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit file_load_exception(const xtd::string& message, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, error, stack_frame) {}
/// @brief Create a new instance of class file_load_exception
/// @deprecated Use xtd::io::file_load_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.
[[deprecated("Use xtd::io::file_load_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 file_load_exception(const xtd::string& message, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::file_load_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 stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit file_load_exception(const xtd::string& message, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, help_link, stack_frame) {}
/// @brief Create a new instance of class file_load_exception
/// @deprecated Use xtd::io::file_load_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.
[[deprecated("Use xtd::io::file_load_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 file_load_exception(const xtd::string& message, const xtd::string& help_link, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::file_load_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.
explicit file_load_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::current()) : io_exception(message, error, help_link, stack_frame) {}
/// @brief Create a new instance of class file_load_exception
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
/// @deprecated Use xtd::io::file_load_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.
[[deprecated("Use xtd::io::file_load_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 file_load_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::current());
/// @brief Create a new instance of class xtd::io::file_load_exception
/// @param inner_exception The exception that is the cause of the current exception.
/// @param stack_frame (optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
/// @remarks Message is set with the default message associate to the exception.
explicit file_load_exception(const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(default_message(), inner_exception, stack_frame) {}
/// @brief Create a new instance of class file_load_exception
/// @deprecated Use xtd::io::file_load_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) - Will be removed in version 0.4.0.
[[deprecated("Use xtd::io::file_load_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) - Will be removed in version 0.4.0.")]]
explicit file_load_exception(const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::file_load_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 stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit file_load_exception(const xtd::string& message, const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : io_exception(message, inner_exception, stack_frame) {}
/// @brief Create a new instance of class file_load_exception
/// @deprecated Use xtd::io::file_load_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) - Will be removed in version 0.4.0.
[[deprecated("Use xtd::io::file_load_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) - Will be removed in version 0.4.0.")]]
explicit file_load_exception(const xtd::string& message, const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current());
/// @brief Create a new instance of class xtd::io::file_load_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 stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit file_load_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::current()) : io_exception(message, inner_exception, error, stack_frame) {}
/// @brief Create a new instance of class file_load_exception
/// @deprecated Use xtd::io::file_load_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::error_code - Will be removed in version 0.4.0.
[[deprecated("Use xtd::io::file_load_exception (const xtd::string& message, const exception_t& inner_exception, 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 file_load_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::current());
/// @brief Create a new instance of class xtd::io::file_load_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 stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit file_load_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::current()) : io_exception(message, inner_exception, help_link, stack_frame) {}
/// @brief Create a new instance of class file_load_exception
/// @deprecated Use xtd::io::file_load_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::help_link - Will be removed in version 0.4.0.
[[deprecated("Use xtd::io::file_load_exception (const xtd::string& message, const exception_t& inner_exception, 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 file_load_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::current());
/// @brief Create a new instance of class xtd::io::file_load_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 stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
explicit file_load_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::current()) : io_exception(message, inner_exception, error, help_link, stack_frame) {}
/// @deprecated Use xtd::io::file_load_exception (const xtd::string& message, const exception_t& inner_exception, 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.
[[deprecated("Use xtd::io::file_load_exception (const xtd::string& message, const exception_t& inner_exception, 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 file_load_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 = null);
/// @}

/// @cond
file_load_exception(const file_load_exception&) = default;
file_load_exception& operator =(const file_load_exception&) = default;
/// @endcond

private:
const char* default_message() const noexcept {return "Could not load the specified file."_t;}
};
}
}
49 changes: 49 additions & 0 deletions src/xtd.core/src/xtd/io/file_load_exception.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "../../../include/xtd/io/file_load_exception.h"

using namespace xtd;
using namespace xtd::diagnostics;
using namespace xtd::io;

file_load_exception::file_load_exception(const stack_frame& stack_frame) : io_exception(stack_frame) {
error_code(h_result::make_error_code(h_result::COR_E_FILELOAD));
}

file_load_exception::file_load_exception(const optional<string>& message, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(h_result::make_error_code(h_result::COR_E_FILELOAD));
}

file_load_exception::file_load_exception(const string& message, const std::error_code& error, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(error);
}

file_load_exception::file_load_exception(const string& message, const string& help_link, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(h_result::make_error_code(h_result::COR_E_FILELOAD));
this->help_link(help_link);
}

file_load_exception::file_load_exception(const string& message, const std::error_code& error, const string& help_link, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(error);
this->help_link(help_link);
}

file_load_exception::file_load_exception(const std::exception& inner_exception, const stack_frame& stack_frame) : io_exception(stack_frame) {
error_code(h_result::make_error_code(h_result::COR_E_FILELOAD));
}

file_load_exception::file_load_exception(const string& message, const std::exception& inner_exception, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(h_result::make_error_code(h_result::COR_E_FILELOAD));
}

file_load_exception::file_load_exception(const string& message, const std::exception& inner_exception, const std::error_code& error, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(error);
}

file_load_exception::file_load_exception(const string& message, const std::exception& inner_exception, const string& help_link, const stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(h_result::make_error_code(h_result::COR_E_FILELOAD));
this->help_link(help_link);
}

file_load_exception::file_load_exception(const string& message, const std::exception& inner_exception, const std::error_code& error, const string& help_link, const xtd::diagnostics::stack_frame& stack_frame) : io_exception(message, stack_frame) {
error_code(error);
this->help_link(help_link);
}
Loading

0 comments on commit 7dd8e78

Please sign in to comment.