2021-09-13 09:37:49 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2021 Haiku, Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _ERRORS_EXT_H
|
|
|
|
#define _ERRORS_EXT_H
|
|
|
|
|
|
|
|
#include <iosfwd>
|
|
|
|
|
|
|
|
#include <String.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
class BDataIO;
|
|
|
|
|
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
namespace Network {
|
|
|
|
|
|
|
|
|
2022-10-30 00:45:39 +03:00
|
|
|
class BError
|
|
|
|
{
|
2021-09-13 09:37:49 +03:00
|
|
|
public:
|
2022-10-30 00:45:39 +03:00
|
|
|
BError(const char* origin);
|
|
|
|
BError(BString origin);
|
|
|
|
virtual ~BError() noexcept;
|
2021-09-13 09:37:49 +03:00
|
|
|
|
2022-10-30 00:45:39 +03:00
|
|
|
BError(const BError& error);
|
|
|
|
BError(BError&& error) noexcept;
|
2021-09-13 09:37:49 +03:00
|
|
|
|
2022-10-30 00:45:39 +03:00
|
|
|
BError& operator=(const BError& error);
|
|
|
|
BError& operator=(BError&& error) noexcept;
|
2021-09-13 09:37:49 +03:00
|
|
|
|
2022-10-30 00:45:39 +03:00
|
|
|
virtual const char* Message() const noexcept = 0;
|
|
|
|
virtual const char* Origin() const noexcept;
|
|
|
|
virtual BString DebugMessage() const;
|
|
|
|
void WriteToStream(std::ostream& stream) const;
|
|
|
|
size_t WriteToOutput(BDataIO* output) const;
|
2021-09-13 09:37:49 +03:00
|
|
|
|
|
|
|
private:
|
2022-10-30 00:45:39 +03:00
|
|
|
virtual void _ReservedError1();
|
|
|
|
virtual void _ReservedError2();
|
|
|
|
virtual void _ReservedError3();
|
|
|
|
virtual void _ReservedError4();
|
2021-09-13 09:37:49 +03:00
|
|
|
|
|
|
|
private:
|
2022-10-30 00:45:39 +03:00
|
|
|
BString fOrigin;
|
2021-09-13 09:37:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-10-30 00:45:39 +03:00
|
|
|
class BRuntimeError : public BError
|
|
|
|
{
|
2021-09-13 09:37:49 +03:00
|
|
|
public:
|
2022-10-30 00:45:39 +03:00
|
|
|
BRuntimeError(const char* origin, const char* message);
|
|
|
|
BRuntimeError(const char* origin, BString message);
|
|
|
|
BRuntimeError(BString origin, BString message);
|
2021-09-13 09:37:49 +03:00
|
|
|
|
2022-10-30 00:45:39 +03:00
|
|
|
BRuntimeError(const BRuntimeError& other);
|
|
|
|
BRuntimeError(BRuntimeError&& other) noexcept;
|
2021-09-13 09:37:49 +03:00
|
|
|
|
2022-10-30 00:45:39 +03:00
|
|
|
BRuntimeError& operator=(const BRuntimeError& other);
|
|
|
|
BRuntimeError& operator=(BRuntimeError&& other) noexcept;
|
2021-09-13 09:37:49 +03:00
|
|
|
|
2022-10-30 00:45:39 +03:00
|
|
|
virtual const char* Message() const noexcept override;
|
2021-09-13 09:37:49 +03:00
|
|
|
|
|
|
|
private:
|
2022-10-30 00:45:39 +03:00
|
|
|
BString fMessage;
|
2021-09-13 09:37:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BSystemError : public BError
|
|
|
|
{
|
|
|
|
public:
|
2022-10-30 00:45:39 +03:00
|
|
|
BSystemError(const char* origin, status_t error);
|
|
|
|
BSystemError(BString origin, status_t error);
|
2021-09-13 09:37:49 +03:00
|
|
|
|
2022-10-30 00:45:39 +03:00
|
|
|
BSystemError(const BSystemError& other);
|
|
|
|
BSystemError& operator=(const BSystemError& other);
|
2021-09-13 09:37:49 +03:00
|
|
|
|
2022-10-30 00:45:39 +03:00
|
|
|
BSystemError(BSystemError&& other) noexcept;
|
|
|
|
BSystemError& operator=(BSystemError&& other) noexcept;
|
2021-09-13 09:37:49 +03:00
|
|
|
|
2022-10-30 00:45:39 +03:00
|
|
|
virtual const char* Message() const noexcept override;
|
|
|
|
virtual BString DebugMessage() const override;
|
|
|
|
status_t Error() noexcept;
|
2021-09-13 09:37:49 +03:00
|
|
|
|
|
|
|
private:
|
2022-10-30 00:45:39 +03:00
|
|
|
status_t fErrorCode;
|
2021-09-13 09:37:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Network
|
|
|
|
|
|
|
|
} // Namespace BPrivate
|
|
|
|
|
|
|
|
#endif // _ERRORS_EXT_H
|