class Hanami::Action::UnknownFormatError

Unknown format error

This error is raised when a action sets a format that it isn’t recognized both by ‘Hanami::Action::Configuration` and the list of Rack mime types

@since 2.0.0

@see Hanami::Action::Mime#format=

Public Class Methods

new(format) click to toggle source

@since 2.0.0 @api private

Calls superclass method
# File lib/hanami/action/errors.rb, line 37
      def initialize(format)
        message = <<~MSG
          Cannot find a corresponding MIME type for format `#{format.inspect}'.
        MSG

        unless blank?(format)
          message += <<~MSG

            Configure one via: `config.actions.formats.add(:#{format}, "MIME_TYPE_HERE")' in `config/app.rb' to share between actions of a Hanami app.

            Or make it available only in the current action: `config.formats.add(:#{format}, "MIME_TYPE_HERE")'.
          MSG
        end

        super(message)
      end

Private Instance Methods

blank?(format) click to toggle source
# File lib/hanami/action/errors.rb, line 56
def blank?(format)
  format.to_s.match(/\A[[:space:]]*\z/)
end