From 7287a7dcd02e571b4518d5e41e4aabc2e867f412 Mon Sep 17 00:00:00 2001 From: Svyatoslav Kryukov Date: Mon, 23 Oct 2023 22:46:40 +0300 Subject: [PATCH] Raise error when parameter attributes misses required keys --- lib/skooma/objects/parameter/keywords/value_parser.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/skooma/objects/parameter/keywords/value_parser.rb b/lib/skooma/objects/parameter/keywords/value_parser.rb index 9f0534a..3014309 100644 --- a/lib/skooma/objects/parameter/keywords/value_parser.rb +++ b/lib/skooma/objects/parameter/keywords/value_parser.rb @@ -9,9 +9,11 @@ module Keywords module ValueParser class << self def call(instance, result) - type = result.sibling(instance, "in").annotation - key = result.sibling(instance, "name").annotation - raise Error, "Missing key: #{key}" unless key + type = result.sibling(instance, "in")&.annotation + raise Error, "Missing `in` key #{result.path}" unless type + + key = result.sibling(instance, "name")&.annotation + raise Error, "Missing `name` key #{instance.path}: #{key}" unless key case type when "query" @@ -30,7 +32,7 @@ def call(instance, result) when "cookie" # instance["headers"]["Cookie"] else - raise Error, "Unknown location: #{result.sibling(instance, "in").annotation}" + raise Error, "Unknown location: #{type}" end end