Permalink
Browse files

Add EmptyQueue error

  • Loading branch information...
1 parent 6ece57e commit ab3f21b7eb86326f0f1608676c2d410f6f71163f Evan Shaw committed Dec 18, 2011
Showing with 6 additions and 1 deletion.
  1. +3 −1 ironmq.go
  2. +3 −0 ironmq_test.go
View
@@ -27,6 +27,8 @@ type Error struct {
Msg string
}
+var EmptyQueue = os.NewError("queue is empty")
+
func (e *Error) String() string { return fmt.Sprintf("Status %d: %s", e.Status, e.Msg) }
func (c *Client) req(method, endpoint string, body []byte) (map[string]interface{}, os.Error) {
@@ -92,7 +94,7 @@ func (q *Queue) Get() (*Message, os.Error) {
}
body, ok := resp["body"].(string)
if !ok {
- return nil, os.NewError("Body is not a string")
+ return nil, EmptyQueue
}
id, ok := resp["id"].(string)
if !ok {
View
@@ -17,6 +17,9 @@ func TestFunctionality(t *testing.T) {
for err == nil {
_, err = queue.Get()
}
+ if err != EmptyQueue {
+ t.Fatalf("queue.Get: expected empty queue error, got: %s", err)
+ }
const body = "Hello, IronMQ!"
err = queue.Push(body)

0 comments on commit ab3f21b

Please sign in to comment.