Module: Brown::AmqpErrors

Included in:
Util
Defined in:
lib/brown/amqp_errors.rb

Instance Method Summary collapse

Instance Method Details

#error_lookup(code) ⇒ Object



22
23
24
# File 'lib/brown/amqp_errors.rb', line 22

def error_lookup(code)
	errors[code]
end

#error_message(code, text, &blk) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/brown/amqp_errors.rb', line 4

def error_message(code, text, &blk)
	details = error_lookup(code)
	message = "#{details[:error_class]} exception: #{code} " +
	          "(#{details[:name]}). #{details[:description]}"

	case code
	when 404
		diagnosis = "looks like the queue has been deleted."
	when 406
		case text
		when /.*(unknown delivery tag [0-9]+).*/
			diagnosis = "#{$1} - you've probably already acknowledged the message."
		end
	else
	end
	blk.call(message, diagnosis)
end

#errorsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/brown/amqp_errors.rb', line 26

def errors
	@errors ||= {
		311 => {
			:name        => "content-too-large",
			:error_class => "Channel",
			:description => "The client attempted to transfer content larger " +
			                "than the server could accept at the present time. " +
			                "The client may retry at a later time."
		},
		313 => {
			:name        => "no-consumers",
			:error_class => "Channel",
			:description => "When the exchange cannot deliver to a consumer " +
			                "when the immediate flag is set. As a result of " +
			                "pending data on the queue or the absence of any " +
			                "consumers of the queue."
		},
		320 => {
			:name        => "connection-forced",
			:error_class => "Connection",
			:description => "An operator intervened to close the Connection " +
			                "for some reason. The client may retry at some " +
			                "later date."
		},
		402 => {
			:name        => "invalid-path",
			:error_class => "Connection",
			:description => "The client tried to work with an unknown virtual host."
		},
		403 => {
			:name        => "access-refused",
			:error_class => "Channel",
			:description => "The client attempted to work with a server " +
			                "entity to which it has no access due to security " +
			                "settings."
		},
		404 => {
			:name        => "not-found",
			:error_class => "Channel",
			:description => "The client attempted to work with a server " +
			                "entity that does not exist."
		},
		405 => {
			:name        => "resource-locked",
			:error_class => "Channel",
			:description => "The client attempted to work with a server " +
			                "entity to which it has no access because " +
			                "another client is working with it."
		},
		406 => {
			:name        => "precondition-failed",
			:error_class => "Channel",
			:description => "The client requested a method that was not " +
			                "allowed because some precondition failed."
		},
		501 => {
			:name        => "frame-error",
			:error_class => "Connection",
			:description => "The sender sent a malformed frame that the " +
			                "recipient could not decode. This strongly " +
			                "implies a programming error in the sending peer."
		},
		502 => {
			:name        => "syntax-error",
			:error_class => "Connection",
			:description => "The sender sent a frame that contained illegal " +
			                "values for one or more fields. This strongly " +
			                "implies a programming error in the sending peer."
		},
		503 => {
			:name        => "command-invalid",
			:error_class => "Connection",
			:description => "The client sent an invalid sequence of frames, " +
			                "attempting to perform an operation that was " +
			                "considered invalid by the server. This usually " +
			                "implies a programming error in the client."
		},
		504 => {
			:name        => "channel-error",
			:error_class => "Connection",
			:description => "The client attempted to work with a Channel that " +
			                "had not been correctly opened. This most likely " +
			                "indicates a fault in the client layer."
		},
		505 => {
			:name        => "unexpected-frame",
			:error_class => "Connection",
			:description => "The peer sent a frame that was not expected, " +
			                "usually in the context of a content header and " +
			                "body. This strongly indicates a fault in the " +
			                "peer's content processing."
		},
		506 => {
			:name        => "resource-error",
			:error_class => "Connection",
			:description => "The server could not complete the method because " +
			                "it lacked sufficient resources. This may be due " +
			                "to the client creating too many of some type of entity."
		},
		530 => {
			:name        => "not-allowed",
			:error_class => "Connection",
			:description => "The client tried to work with some entity in a " +
			                "manner that is prohibited by the server, due to " +
			                "security settings or by some other criteria."
		},
		540 => {
			:name        => "not-implemented",
			:error_class => "Connection",
			:description => "The client tried to use functionality that is " +
			                "not implemented in the server."
		},
		541 => {
			:name        => "internal-error",
			:error_class => "Connection",
			:description => "The server could not complete the method " +
			                "because of an internal error. The server may " +
			                "require intervention by an operator in order " +
			                "to resume normal operations."
		}
	}
end