2023-02-12 10:04:05 +00:00
|
|
|
use errors;
|
2023-02-10 09:13:30 +00:00
|
|
|
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_NOTFOUND]] are not handled by this type.
|
2023-02-12 10:04:05 +00:00
|
|
|
export type error = !(dial::error | io::error | errors::unsupported | protoerr);
|
2023-02-11 10:03:51 +00:00
|
|
|
|
|
|
|
// An HTTP protocol error occurred, indicating that the remote party is not
|
|
|
|
// conformant with HTTP semantics.
|
2023-02-12 10:04:05 +00:00
|
|
|
export type protoerr = !void;
|
2023-02-10 09:13:30 +00:00
|
|
|
|
|
|
|
// 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);
|
2023-02-12 10:04:05 +00:00
|
|
|
case errors::unsupported =>
|
|
|
|
return "Unsupported HTTP feature";
|
2023-02-11 10:03:51 +00:00
|
|
|
case protoerr =>
|
|
|
|
return "HTTP protocol error";
|
2023-02-10 09:13:30 +00:00
|
|
|
};
|
|
|
|
};
|