Sha256: 4cd25b5e3d5f1e502d0032c6b06c1103345297a00f544a59bfe78b3d0ab942b5

Contents?: true

Size: 994 Bytes

Versions: 12

Compression:

Stored size: 994 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(args)
        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.15.0.beta.7-x86_64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.15.0.beta.7-aarch64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.15.0.beta.7-arm64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.15.0.beta.7-x86_64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.15.0.beta.6-x86_64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.15.0.beta.6-aarch64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.15.0.beta.6-arm64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.15.0.beta.6-x86_64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.15.0.beta.5-x86_64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.15.0.beta.5-aarch64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.15.0.beta.5-arm64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.15.0.beta.5-x86_64-darwin lib/proscenium/middleware/esbuild.rb