From 9c90ebc38c2ca4fc01fe60589c7c3d1dd6e9f403 Mon Sep 17 00:00:00 2001 From: Nick Elser Date: Thu, 7 May 2015 00:25:42 -0700 Subject: [PATCH] nicer error messages --- lib/zhong/job.rb | 2 +- lib/zhong/scheduler.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/zhong/job.rb b/lib/zhong/job.rb index 2478b0a..4a50990 100644 --- a/lib/zhong/job.rb +++ b/lib/zhong/job.rb @@ -13,7 +13,7 @@ def initialize(name, config = {}, &block) @logger.error "warning: #{self} has `at` but no `every`; could run far more often than expected!" end - fail "must specific either `at` or `every` for a job" unless @at || @every + fail "must specific either `at` or `every` for job: #{self}" unless @at || @every @block = block diff --git a/lib/zhong/scheduler.rb b/lib/zhong/scheduler.rb index c4b3f63..1b124ee 100644 --- a/lib/zhong/scheduler.rb +++ b/lib/zhong/scheduler.rb @@ -19,7 +19,7 @@ def initialize(config = {}) end def category(name) - fail "cannot nest categories: #{name} would be nested in #{@category}" if @category + fail "cannot nest categories: #{name} would be nested in #{@category} (#{caller.first})" if @category @category = name.to_s @@ -29,6 +29,7 @@ def category(name) end def every(period, name, opts = {}, &block) + fail "must specify a period for #{name} (#{caller.first})" unless period job = Job.new(name, opts.merge(@config).merge(every: period, category: @category), &block) add(job) end