NetServices: Add the BNetworkRequestError type

This is a generic error type that can be used by multiple protocols to describe errors that can
occur while processing a request. The error type supports adding an additional error code in cases
where there is an underlying system error.

The type will be used to describe errors that occur while processing requests by BHttpSession, and
it is generally going to be thrown by the receiving BHttpResult.

Change-Id: I76c0bbaedd38df8cfb79159c4beae2fbf1350aab
This commit is contained in:
Niels Sascha Reedijk
2022-03-07 07:59:03 +00:00
parent 1baacbfebf
commit 3b2aa6c31b
4 changed files with 218 additions and 3 deletions
@@ -50,6 +50,31 @@ private:
};
class BNetworkRequestError : public BError {
public:
enum ErrorType {
HostnameError,
NetworkError,
ProtocolError,
SystemError,
Canceled
};
BNetworkRequestError(const char* origin, ErrorType type,
status_t errorCode = B_OK);
virtual const char* Message() const noexcept override;
virtual BString DebugMessage() const override;
ErrorType Type() const noexcept;
status_t ErrorCode() const noexcept;
private:
ErrorType fErrorType;
status_t fErrorCode = B_OK;
};
}
}