Sha256: 8141d341a0715c7e87f915cbd63874d597fc8c0c2bd40387cf2ae31168c04754

Contents?: true

Size: 998 Bytes

Versions: 10

Compression:

Stored size: 998 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 Proscenium::Builder.build(path_to_build, root: root,
                                                                 base_url: @request.base_url)
      rescue Proscenium::Builder::CompileError => e
        raise self.class::CompileError, { file: @request.fullpath, detail: e.message }, caller
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
proscenium-0.11.0.pre.3-arm64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.3-x86_64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.2-x86_64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.2-aarch64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.2-arm64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.2-x86_64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.1-x86_64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.1-aarch64-linux lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.1-arm64-darwin lib/proscenium/middleware/esbuild.rb
proscenium-0.11.0.pre.1-x86_64-darwin lib/proscenium/middleware/esbuild.rb