2024-12-03 17:30:36 -03:00
|
|
|
#ifndef CSHARP_IO_EXCEPTION_HPP
|
|
|
|
#define CSHARP_IO_EXCEPTION_HPP
|
|
|
|
|
|
|
|
#include "../exception.hpp"
|
|
|
|
#include <source_location>
|
|
|
|
|
|
|
|
namespace csharp {
|
|
|
|
class IOException : public SystemException {
|
|
|
|
public:
|
2024-12-04 09:28:03 -03:00
|
|
|
IOException(OptionalString const& message = std::nullopt, std::source_location const& source = std::source_location::current())
|
|
|
|
: SystemException(message.value_or(SR::Arg_IOException), source)
|
2024-12-03 17:30:36 -03:00
|
|
|
{
|
|
|
|
HRresult = HResults::HR_COR_E_IO;
|
|
|
|
}
|
|
|
|
|
2024-12-04 09:28:03 -03:00
|
|
|
IOException(OptionalString const& message, size_t hresult, std::source_location const& source = std::source_location::current())
|
|
|
|
: SystemException(message.value_or(SR::Arg_IOException), source)
|
2024-12-03 17:30:36 -03:00
|
|
|
{
|
|
|
|
HRresult = hresult;
|
|
|
|
}
|
|
|
|
|
2024-12-04 09:28:03 -03:00
|
|
|
IOException(OptionalString const& message, std::shared_ptr<Exception>& innerException, std::source_location const& source = std::source_location::current())
|
|
|
|
: SystemException(message.value_or(SR::Arg_IOException), innerException, source)
|
2024-12-03 17:30:36 -03:00
|
|
|
{
|
|
|
|
HRresult = HResults::HR_COR_E_IO;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class EndOfStreamException : public IOException {
|
|
|
|
public:
|
2024-12-04 09:28:03 -03:00
|
|
|
EndOfStreamException(OptionalString const& message = std::nullopt, std::source_location const& source = std::source_location::current())
|
|
|
|
: IOException(message.value_or(SR::Arg_IOException), source)
|
2024-12-03 17:30:36 -03:00
|
|
|
{
|
|
|
|
HRresult = HResults::HR_COR_E_ENDOFSTREAM;
|
|
|
|
}
|
|
|
|
|
2024-12-04 09:28:03 -03:00
|
|
|
EndOfStreamException(OptionalString const& message, std::shared_ptr<Exception>& innerException, std::source_location const& source = std::source_location::current())
|
|
|
|
: IOException(message.value_or(SR::Arg_IOException), innerException, source)
|
2024-12-03 17:30:36 -03:00
|
|
|
{
|
|
|
|
HRresult = HResults::HR_COR_E_ENDOFSTREAM;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|