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.



107
108
109
110
# File 'lib/sinatra_opal_patches.rb', line 107

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

Instance Attribute Details

#payloadObject (readonly)

Returns the value of attribute payload.



105
106
107
# File 'lib/sinatra_opal_patches.rb', line 105

def payload
  @payload
end