Skip to main content

orca/
errors.rs

1/// An enum containing possible errors from a request to reddit
2#[derive(Debug, Fail)]
3pub enum RedditError {
4	/// The requested resource was not found
5	#[fail(display = "Requested resource {} was not found", request)]
6	NotFound {
7		/// The requested resource
8		request: String,
9	},
10	/// The requested resource is forbidden
11	#[fail(display = "Requested resource {} is forbidden", request)]
12	Forbidden {
13		/// The requested resource
14		request: String,
15	},
16	/// Recieved a response that was unexpected
17	#[fail(display = "\nSent request {}, got unexpected reponse {}\n", request, response)]
18	BadResponse {
19		/// The request that was sent
20		request: String,
21		/// The response that was recieved
22		response: String,
23	},
24	/// A request was sent that was incorrect
25	#[fail(display = "\nAttempted incorrect request {} got response {}\n", request, response)]
26	BadRequest {
27		/// The request that was sent
28		request: String,
29		/// The response that was recieved
30		response: String,
31	},
32	/// Authorization failed
33	#[fail(display = "Failed to authorize")]
34	AuthError,
35}
36
37/// An error representing a json value that could not be parsed as a certain struct
38#[derive(Debug, Fail)]
39#[fail(display = "Could not parse json {} as {}\n", json, thing_type)]
40pub struct ParseError {
41	/// The type the json was attempted to be parsed as
42	pub thing_type: String,
43	/// The json that was attempted to be parsed
44	pub json: String,
45}