forked from OpenNeo/impress
404 on bad page type name
This commit is contained in:
parent
b9e3d7bff5
commit
dfb3aeb9de
2 changed files with 8 additions and 2 deletions
|
@ -6,6 +6,7 @@ class NeopetsPageImportTasksController < ApplicationController
|
|||
before_filter :require_source, only: [:create]
|
||||
|
||||
rescue_from NeopetsPage::ParseError, with: :on_parse_error
|
||||
rescue_from NeopetsPage::TypeNotFound, with: :not_found
|
||||
|
||||
def create
|
||||
neopets_page = NeopetsPage.new(params[:page_type], params[:expected_index].to_i, params[:neopets_page][:source])
|
||||
|
|
|
@ -10,7 +10,11 @@ class NeopetsPage
|
|||
|
||||
|
||||
def initialize(type_key, expected_index, source)
|
||||
@type = TYPES.fetch(type_key)
|
||||
begin
|
||||
@type = TYPES.fetch(type_key)
|
||||
rescue KeyError
|
||||
raise TypeNotFound, type_key
|
||||
end
|
||||
@expected_index = expected_index
|
||||
@source = source
|
||||
end
|
||||
|
@ -354,5 +358,6 @@ class NeopetsPage
|
|||
end
|
||||
|
||||
|
||||
class ParseError < RuntimeError;end
|
||||
class ParseError < RuntimeError; end
|
||||
class TypeNotFound < RuntimeError; end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue