Skip to content

Commit ad7bfb1

Browse files
author
Matthew Peck
committed
add no_enabled and not_in_bundle errors to the command resolver
1 parent f284264 commit ad7bfb1

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

lib/cog/command/command_resolver.ex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ defmodule Cog.Command.CommandResolver do
2323
%SiteCommandAlias{pipeline: pipeline} ->
2424
{:pipeline, pipeline}
2525
:not_found ->
26-
:not_found
26+
{:error, :not_found}
27+
{:not_enabled, bundle_name} ->
28+
{:error, {:not_enabled, bundle_name}}
29+
{:not_in_bundle, bundle_name} ->
30+
{:error, {:not_in_bundle, bundle_name}}
2731
{:ambiguous, names} ->
28-
{:ambiguous, names}
32+
{:error, {:ambiguous, names}}
2933
end
3034
end
3135
end
@@ -51,13 +55,13 @@ defmodule Cog.Command.CommandResolver do
5155
case Map.get(enabled_bundles, bundle_name) do
5256
nil ->
5357
# No enabled version of the requested bundle was found
54-
:not_found
58+
{:not_enabled, bundle_name}
5559
version ->
5660
case Bundles.command_for_bundle_version(command_name, bundle_name, version) do
5761
nil ->
5862
# The enabled bundle version does not contain the
5963
# requested command
60-
:not_found
64+
{:not_in_bundle, bundle_name}
6165
result ->
6266
{:ok, rules} = Rules.rules_for_command(result.command)
6367
Cog.Command.Pipeline.ParserMeta.new(result.command.bundle.name,

mix.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ defmodule Cog.Mixfile do
6666
{:greenbar, github: "operable/greenbar"},
6767
{:probe, github: "operable/probe"},
6868
{:spanner, github: "operable/spanner"},
69+
# This is just here until I get piper updated everywhere
70+
{:piper, github: "operable/piper", branch: "peck/error-messages", override: true},
6971

7072
# MQTT-related
7173
########################################################################

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"phoenix_html": {:hex, :phoenix_html, "2.7.0", "19e12e2044340c2e43df206a06d059677c59ea1868bd1c35165438d592cd420b", [:mix], [{:plug, "~> 1.0", [hex: :plug, optional: false]}]},
5555
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.0.5", "829218c4152ba1e9848e2bf8e161fcde6b4ec679a516259442561d21fde68d0b", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, optional: false]}, {:phoenix, "~> 1.0 or ~> 1.2-rc", [hex: :phoenix, optional: false]}]},
5656
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.1", "c10ddf6237007c804bf2b8f3c4d5b99009b42eca3a0dfac04ea2d8001186056a", [:mix], []},
57-
"piper": {:git, "https://github.com/operable/piper.git", "0afedeb326e5ce686daf83a4ed203890e1ad7fe8", []},
57+
"piper": {:git, "https://github.com/operable/piper.git", "decef8846fba349058f3123fc8e5567e0a15cab5", [branch: "peck/error-messages"]},
5858
"plug": {:hex, :plug, "1.2.2", "cfbda521b54c92ab8ddffb173fbaabed8d8fc94bec07cd9bb58a84c1c501b0bd", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]},
5959
"poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []},
6060
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []},

0 commit comments

Comments
 (0)