1
Fork 0
hare-playground/vendor/hare-http/net/http/error.ha
2024-06-01 16:46:01 +02:00

27 lines
821 B
Hare

use errors;
use io;
use net::dial;
// Errors possible while servicing HTTP requests. Note that these errors are for
// errors related to the processing of the HTTP connection; semantic HTTP errors
// such as [[STATUS_NOT_FOUND]] are not handled by this type.
export type error = !(dial::error | io::error | errors::unsupported | protoerr);
// An HTTP protocol error occurred, indicating that the remote party is not
// conformant with HTTP semantics.
export type protoerr = !void;
// Converts an [[error]] to a string.
export fn strerror(err: error) const str = {
match (err) {
case let err: dial::error =>
return dial::strerror(err);
case let err: io::error =>
return io::strerror(err);
case errors::unsupported =>
return "Unsupported HTTP feature";
case protoerr =>
return "HTTP protocol error";
};
};