Skip to content

Commit

Permalink
nicer error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nickelser committed May 7, 2015
1 parent a13f086 commit 9c90ebc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/zhong/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion lib/zhong/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 9c90ebc

Please sign in to comment.