Navigation Menu

Skip to content

Commit

Permalink
Define status codes in a shared module
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Feb 17, 2014
1 parent ed93264 commit 76e5ea3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lib/droonga/message_processing_error.rb
Expand Up @@ -14,10 +14,11 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

require "droonga/error"
require "droonga/status_code"

module Droonga
class MessageProcessingError < Error
STATUS_CODE = 500
STATUS_CODE = STATUS_INTERNAL_ERROR

attr_reader :message, :detail

Expand Down Expand Up @@ -45,10 +46,10 @@ def response_body
end

class BadRequest < MessageProcessingError
STATUS_CODE = 400
STATUS_CODE = STATUS_BAD_REQUEST
end

class NotFound < MessageProcessingError
STATUS_CODE = 404
STATUS_CODE = STATUS_NOT_FOUND_REQUEST
end
end
2 changes: 2 additions & 0 deletions lib/droonga/output_message.rb
Expand Up @@ -13,6 +13,8 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

require "droonga/status_code"

module Droonga
class OutputMessage
def initialize(raw_message)
Expand Down
4 changes: 2 additions & 2 deletions lib/droonga/replier.rb
Expand Up @@ -13,10 +13,10 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

require "droonga/status_code"

module Droonga
class Replier
STATUS_OK = 200

def initialize(forwarder)
@forwarder = forwarder
end
Expand Down
23 changes: 23 additions & 0 deletions lib/droonga/status_code.rb
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2014 Droonga Project
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

module Droonga
STATUS_OK = 200
STATUS_BAD_REQUEST = 400
STATUS_NOT_FOUND = 404
STATUS_INTERNAL_ERROR = 500
end

0 comments on commit 76e5ea3

Please sign in to comment.