ftl_protocol/protocol/
error.rs1use std::string::ToString;
2
3#[derive(Debug)]
4pub enum FtlError {
5 IoError,
6 AllocateError,
7 RingError,
8 DecodeError,
9 MissingPart,
10
11 InvalidStreamKey, ChannelNotAuthorized,
13 ChannelInUse,
14 UnsupportedRegion,
15 GameBlocked,
16
17 InvalidProtocolVersion,
18 UnsupportedProtocolVersion,
19 MissingCodecInformation,
20 UnimplementedCommand,
21
22 Disconnect,
23}
24
25impl FtlError {
26 pub fn is_err(&self) -> bool {
27 match self {
28 FtlError::Disconnect => false,
29 _ => true
30 }
31 }
32}
33
34impl ToString for FtlError {
35 fn to_string(&self) -> String {
36 match self {
37 FtlError::IoError => "500 Internal Server Error\n".to_string(),
38 FtlError::AllocateError => "500 Internal Server Error\n".to_string(),
39 FtlError::RingError => "400 HMAC Decode Error\n".to_string(),
40 FtlError::DecodeError => "400 HMAC Decode Error\n".to_string(),
41 FtlError::MissingPart => "400 Bad Request\n".to_string(),
42
43 FtlError::InvalidStreamKey => "405 Invalid stream key\n".to_string(),
44 FtlError::ChannelNotAuthorized => "401 Channel not authorized to stream\n".to_string(),
45 FtlError::ChannelInUse => "406 Channel actively streaming\n".to_string(),
46 FtlError::UnsupportedRegion => "407 Streaming from your region is not authorized\n".to_string(),
47 FtlError::GameBlocked => "409 Channel is not allowed to stream set game\n".to_string(),
48
49 FtlError::InvalidProtocolVersion => "400 Invalid Protocol Version\n".to_string(),
50 FtlError::UnsupportedProtocolVersion => "402 Outdated FTL SDK version\n".to_string(),
51 FtlError::MissingCodecInformation => "400 Missing Codec Information\n".to_string(),
52 FtlError::UnimplementedCommand => "901 Invalid Command\n".to_string(),
53 _ => "".to_string(),
54 }
55 }
56}