lib/hanami.rb in hanami-2.0.0.alpha6 vs lib/hanami.rb in hanami-2.0.0.alpha7
- old
+ new
@@ -1,21 +1,27 @@
# frozen_string_literal: true
+require_relative "hanami/application"
+require_relative "hanami/errors"
+require_relative "hanami/version"
+
+
# A complete web framework for Ruby
#
# @since 0.1.0
#
# @see http://hanamirb.org
module Hanami
- require "hanami/version"
- require "hanami/application"
-
@_mutex = Mutex.new
def self.application
@_mutex.synchronize do
- raise "Hanami.application not configured" unless defined?(@_application)
+ unless defined?(@_application)
+ raise ApplicationLoadError,
+ "Hanami.application is not yet configured. " \
+ "You may need to `require \"hanami/setup\"` to load your config/application.rb file."
+ end
@_application
end
end
@@ -23,10 +29,12 @@
defined?(@_application)
end
def self.application=(klass)
@_mutex.synchronize do
- raise "Hanami.application already configured" if defined?(@_application)
+ if defined?(@_application)
+ raise ApplicationLoadError, "Hanami.application is already configured."
+ end
@_application = klass unless klass.name.nil?
end
end