PSPDFKit-labs / bypass

Bypass provides a quick way to create a custom plug that can be put in place instead of an actual HTTP server to return prebaked responses to client requests.
https://hex.pm/packages/bypass
MIT License
964 stars 111 forks source link

Raise on Bypass.open/1 errors #106

Closed thiamsantos closed 3 years ago

thiamsantos commented 4 years ago

Motivation

According to comment https://github.com/PSPDFKit-labs/bypass/pull/92#issuecomment-638101755 bypass takes the approach of trying to crash during the startup to avoid adding to the user the burden to handle errors. However the open/1 function returns an error tuple in case any problem happens during the process start.

Proposed solution

Based on the start_supervised!/2 function from ex_unit, https://github.com/elixir-lang/elixir/blob/master/lib/ex_unit/lib/ex_unit/callbacks.ex#L424, raise an exception in case any error happens when starting the bypass process at Bypass.open/1.