module FlexCommerceApi
  module Error
    class InternalServer < Base
      def message
        body = response_env.fetch(:body, {errors: []})
        error = body[:errors].first
        if error
          title = error.fetch(:title, "")
          detail = error.fetch(:detail, "")
          backtrace = error.fetch(:meta, {backtrace: []}).fetch(:backtrace)
          "Internal server error - #{title} #{detail} #{backtrace}"
        else
          "Internal server error"
        end
      end

    end
  end
end
module FlexCommerceApi
  module Error
    class InternalServer < Base
      def message
        body = response_env.fetch(:body, {errors: []})
        error = body.is_a?(::String) ? body : body[:errors].first
        return "Internal server error" unless error.present?
        if error.is_a?(::Enumerable)
          title = error.fetch(:title, "")
          detail = error.fetch(:detail, "")
          backtrace = error.fetch(:meta, {backtrace: []}).fetch(:backtrace)
          "Internal server error - #{title} #{detail} #{backtrace}"
        else
          "Internal server error - #{error}"
        end
      end

    end
  end
end
Fix for when fastly errors are returned
Fix for when fastly errors are returned