Navigation Menu

Skip to content

Commit

Permalink
Raise custom error for syntax error of catalog.json
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Feb 12, 2014
1 parent 330900d commit 2da7b05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/droonga/catalog.rb
Expand Up @@ -21,4 +21,13 @@ module Droonga
class << self
attr_accessor :catalog
end

class InvalidCatalog < StandardError
attr_reader :message, :detail

def initialize(message, detail=nil)
@message = message
@detail = detail
end
end
end
2 changes: 2 additions & 0 deletions lib/droonga/catalog_loader.rb
Expand Up @@ -28,6 +28,8 @@ def load
JSON.parse(file.read)
end
Catalog::Version1.new(data, File.dirname(@path))
rescue JSON::ParserError => error
raise InvalidCatalog.new("Syntax error in #{@path}", error)
end
end
end

0 comments on commit 2da7b05

Please sign in to comment.