Sha256: 715f975876ddb4aec83bc0aedd2fb42de71843084f3db4abec65f27836dcca73

Contents?: true

Size: 988 Bytes

Versions: 12

Compression:

Stored size: 988 Bytes

Contents

# frozen_string_literal: true

module Proscenium
  class Middleware
    class Esbuild < Base
      class CompileError < Base::CompileError
        def initialize(args)
          detail = args[:detail]
          detail = ActiveSupport::HashWithIndifferentAccess.new(Oj.load(detail, mode: :strict))

          args[:detail] = if detail[:location]
                            "#{detail[:text]} in #{detail[:location][:file]}:" +
                              detail[:location][:line].to_s
                          else
                            detail[:text]
                          end

          super
        end
      end

      def attempt
        render_response Builder.build_to_string(path_to_build, root: Rails.root.to_s,
                                                               base_url: @request.base_url)
      rescue Builder::CompileError => e
        raise self.class::CompileError, { file: @request.fullpath, detail: e.message }, caller
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
proscenium-0.18.0-x86_64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.18.0-aarch64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.18.0-arm64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.18.0-x86_64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.17.0-x86_64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.17.0-aarch64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.17.0-arm64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.17.0-x86_64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.16.0-aarch64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.16.0-arm64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.16.0-x86_64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.16.0 lib/proscenium/middleware/esbuild.rb