keichan34 / exfile

File upload persistence and processing for Phoenix / Plug
MIT License
90 stars 19 forks source link

Fail hard when a backend fails to initialize, don't store the error return value in the backend repository #15

Closed keichan34 closed 8 years ago

keichan34 commented 8 years ago
Server: localhost:4000 (http)
Request: POST /attachments/cache
** (exit) an exception was raised:
    ** (UndefinedFunctionError) undefined function :error.backend_mod/1 (module :error is not available)
        :error.backend_mod({:error, :enoent})
        (exfile) Exfile.Backend.upload/2
        (exfile) lib/exfile/router.ex:172: Exfile.Router.process_uploaded_file/3 
        (exfile) lib/exfile/router.ex:1: Exfile.Router.plug_builder_call/2
        (phoenix) lib/phoenix/router/route.ex:157: Phoenix.Router.Route.forward/4
        (my_app) lib/phoenix/router.ex:261: MyApp.Router.dispatch/2
        (my_app) web/router.ex:1: MyApp.Router.do_call/2
        (my_app) lib/my_app/endpoint.ex:1: MyApp.Endpoint.phoenix_pipeline/1
keichan34 commented 8 years ago

This error occurs when Exfile.Config.get_backend("backend name") has a return value of {:error, :enoent}. In this case, it was the cache backend, so it was trying to make the cache directory and probably failed.