tokio_beanstalkd/errors.rs
1//! The errors returned by the different operations in the library
2
3/// Errors that can be returned for any command
4#[derive(Copy, Clone, Debug, Eq, PartialEq, Fail)]
5pub enum BeanstalkError {
6 /// The client sent a command line that was not well-formed. This can happen if the line does not
7 /// end with \r\n, if non-numeric characters occur where an integer is expected, if the wrong
8 /// number of arguments are present, or if the command line is mal-formed in any other way.
9 ///
10 /// This should not happen, if it does please file an issue.
11 #[fail(display = "Client command was not well formatted")]
12 BadFormat,
13
14 /// The server cannot allocate enough memory for the job. The client should try again later.
15 #[fail(display = "Server out of memory")]
16 OutOfMemory,
17
18 /// This indicates a bug in the server. It should never happen. If it does happen, please report it
19 /// at http://groups.google.com/group/beanstalk-talk.
20 #[fail(display = "Internal server error")]
21 InternalError,
22 /// The client sent a command that the server does not know.
23 ///
24 /// This should not happen, if it does please file an issue.
25 #[fail(display = "Unknown command sent by client")]
26 UnknownCommand,
27
28 #[fail(display = "An unexpected response occurred")]
29 UnexpectedResponse,
30
31 #[doc(hidden)]
32 #[fail(display = "Just an extention..")]
33 __Nonexhaustive,
34}
35
36/// Errors which can be casued due to a PUT command
37#[derive(Copy, Clone, Debug, Eq, PartialEq, Fail)]
38pub enum Put {
39 /// The server ran out of memory trying to grow the priority queue data structure.
40 /// The client should try another server or disconnect and try again later.
41 #[fail(display = "Server had to bury the request")]
42 Buried,
43
44 /// The job body must be followed by a CR-LF pair, that is, "\r\n". These two bytes are not counted
45 /// in the job size given by the client in the put command line.
46 ///
47 /// This should never happen, if it does please file an issue.
48 #[fail(display = "CRLF missing from the end of command")]
49 ExpectedCRLF,
50
51 /// The client has requested to put a job with a body larger than max-job-size bytes
52 #[fail(display = "Job size exceeds max-job-size bytes")]
53 JobTooBig,
54
55 /// This means that the server has been put into "drain mode" and is no longer accepting new jobs.
56 /// The client should try another server or disconnect and try again later.
57 #[fail(display = "Server is in drain mode")]
58 Draining,
59
60 #[fail(display = "A protocol error occurred: {}", error)]
61 Beanstalk { error: BeanstalkError },
62
63 #[doc(hidden)]
64 #[fail(display = "Just an extention..")]
65 __Nonexhaustive,
66}
67
68/// Errors which can occur when acting as a consumer/worker
69#[derive(Copy, Clone, Debug, Eq, PartialEq, Fail)]
70pub enum Consumer {
71 /// If the job does not exist or is not either reserved by the client
72 #[fail(display = "Did not find a job of that Id")]
73 NotFound,
74 /// if the server ran out of memory trying to grow the priority queue data structure.
75 #[fail(display = "Job got buried")]
76 Buried,
77 /// If the client attempts to ignore the only tube in its watch list.
78 #[fail(display = "Tried to ignore the only tube being watched")]
79 NotIgnored,
80
81 #[fail(display = "A protocol error occurred: {}", error)]
82 Beanstalk { error: BeanstalkError },
83
84 #[doc(hidden)]
85 #[fail(display = "Just an extention..")]
86 __Nonexhaustive,
87}