diff --git a/lib/crontab/cron_expression/parser.ex b/lib/crontab/cron_expression/parser.ex index ddfeb95..8a13dc2 100644 --- a/lib/crontab/cron_expression/parser.ex +++ b/lib/crontab/cron_expression/parser.ex @@ -349,7 +349,7 @@ defmodule Crontab.CronExpression.Parser do {number, ""} -> {:ok, number} - :error -> + _ -> {:error, "Can't parse " <> value <> " as interval " <> Atom.to_string(interval) <> "."} end end diff --git a/test/crontab/cron_expression/parser_test.exs b/test/crontab/cron_expression/parser_test.exs index e71d3ad..ebadd86 100644 --- a/test/crontab/cron_expression/parser_test.exs +++ b/test/crontab/cron_expression/parser_test.exs @@ -374,6 +374,10 @@ defmodule Crontab.CronExpression.ParserTest do assert parse("*/0") == {:error, "Can't parse 0 as increment."} end + test "parse invalid year expression gives error" do + assert parse("* * * * * 1x") == {:error, "Can't parse 1x as interval year."} + end + describe "parse/2 non-range step value" do setup do: %{now: ~N[2024-01-01 00:00:01]}