Exception: QueryStream::UnknownKeyError
- Defined in:
- lib/query_stream/errors.rb
Overview
テンプレートに、データレコードが持たないキーが書かれている
「どのキーが無いか」だけでなく「代わりに何が使えるか」「どのファイルを直すか」まで 属性で渡す。呼び出し元はこれを使って「もしかして =author?」のような案内を組み立てられる。 属性が無かった頃はこのクラスだけが gem 内で logger.error を呼んでおり、 利用できるキーの一覧を呼び出し元が受け取れなかった。
location(記法の位置)と template_path(雛形の位置)は別物である。 直すのは雛形なので、記法の位置だけでは著者はファイルを開けない。
Instance Attribute Summary collapse
-
#available_keys ⇒ Array<Symbol>
readonly
レコードが実際に持つキー.
-
#key_path ⇒ String
readonly
テンプレートに書かれていたキー("author.name" 等).
-
#location ⇒ String
readonly
記法が書かれていたソースファイル名と行番号.
-
#template_path ⇒ String?
readonly
打ち間違いがあるテンプレートのパス.
Instance Method Summary collapse
-
#initialize(msg = nil, key_path: nil, available_keys: [], template_path: nil, location: nil) ⇒ UnknownKeyError
constructor
A new instance of UnknownKeyError.
Constructor Details
#initialize(msg = nil, key_path: nil, available_keys: [], template_path: nil, location: nil) ⇒ UnknownKeyError
Returns a new instance of UnknownKeyError.
71 72 73 74 75 76 77 |
# File 'lib/query_stream/errors.rb', line 71 def initialize(msg = nil, key_path: nil, available_keys: [], template_path: nil, location: nil) super(msg || "テンプレートに存在しないキーが記述されています: #{key_path}") @key_path = key_path @available_keys = Array(available_keys) @template_path = template_path @location = location end |
Instance Attribute Details
#available_keys ⇒ Array<Symbol> (readonly)
レコードが実際に持つキー
68 69 70 |
# File 'lib/query_stream/errors.rb', line 68 def available_keys @available_keys end |
#key_path ⇒ String (readonly)
テンプレートに書かれていたキー("author.name" 等)
68 69 70 |
# File 'lib/query_stream/errors.rb', line 68 def key_path @key_path end |
#location ⇒ String (readonly)
記法が書かれていたソースファイル名と行番号
68 69 70 |
# File 'lib/query_stream/errors.rb', line 68 def location @location end |
#template_path ⇒ String? (readonly)
打ち間違いがあるテンプレートのパス
68 69 70 |
# File 'lib/query_stream/errors.rb', line 68 def template_path @template_path end |