Exception: Sinatra::HaltResponse

Inherits:
Exception
  • Object
show all
Defined in:
lib/sinatra_opal_patches.rb

Overview


1.5. HaltResponse

‘throw :halt` cannot cross an async boundary in Opal: once a `# await: true` route has yielded to a Promise, the eventual throw resumes on a later tick and bypasses Sinatra’s outer ‘catch(:halt)`. We therefore represent explicit `halt` calls as an Exception carrying the fully-materialized Rack tuple. Synchronous routes still terminate immediately; async routes can resolve the rejection back into a response in `invoke` / `build_js_response`.


Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ HaltResponse

Returns a new instance of HaltResponse.



53
54
55
56
# File 'lib/sinatra_opal_patches.rb', line 53

def initialize(payload)
  @payload = payload
  super('halt')
end

Instance Attribute Details

#payloadObject (readonly)

Returns the value of attribute payload.



51
52
53
# File 'lib/sinatra_opal_patches.rb', line 51

def payload
  @payload
end