Skip to content

Commit e62c7e8

Browse files
author
Simon MacMullen
committed
Validate on list
1 parent a7ca9e9 commit e62c7e8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/rabbit_runtime_parameters.erl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ list(VHost) -> list(VHost, '_').
140140
list_component(Component) -> list('_', Component).
141141

142142
list(VHost, Component) ->
143+
assert_vhost(VHost),
143144
Match = #runtime_parameters{key = {VHost, Component, '_'}, _ = '_'},
144145
[p(P) || #runtime_parameters{key = {_VHost, Comp, _Name}} = P <-
145146
mnesia:dirty_match_object(?TABLE, Match),
@@ -148,6 +149,12 @@ list(VHost, Component) ->
148149
list_formatted(VHost) ->
149150
[pset(value, format(pget(value, P)), P) || P <- list(VHost)].
150151

152+
assert_vhost('_') -> ok;
153+
assert_vhost(VHost) -> case rabbit_vhost:exists(VHost) of
154+
true -> ok;
155+
false -> throw({error, {no_such_vhost, VHost}})
156+
end.
157+
151158
lookup(VHost, Component, Name) ->
152159
case lookup0(VHost, Component, Name, rabbit_misc:const(not_found)) of
153160
not_found -> not_found;

0 commit comments

Comments
 (0)