30 lines
757 B
C++
30 lines
757 B
C++
#pragma once
|
|
|
|
// Transport-level WebSocket failure. Messages never carry URLs with query
|
|
// strings or credentials.
|
|
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
namespace molo::google::live {
|
|
|
|
class WsError : public std::runtime_error {
|
|
public:
|
|
enum class Kind { Invalid, Io, Timeout, Handshake, Protocol, TooBig, Closed };
|
|
|
|
WsError(Kind kind, const std::string& message, int http_status = 0)
|
|
: std::runtime_error("molo::google::live::ws: " + message),
|
|
kind_(kind),
|
|
http_status_(http_status) {}
|
|
|
|
Kind kind() const noexcept { return kind_; }
|
|
// HTTP status of a refused upgrade, else 0.
|
|
int http_status() const noexcept { return http_status_; }
|
|
|
|
private:
|
|
Kind kind_;
|
|
int http_status_;
|
|
};
|
|
|
|
} // namespace molo::google::live
|