@@ -284,41 +284,47 @@ defmodule Absinthe.Plug do
284284 @ doc """
285285 Parses, validates, resolves, and executes the given Graphql Document
286286 """
287- @ spec call ( Plug.Conn . t ( ) , map ) :: Plug.Conn . t ( ) | no_return
288- def call ( conn , config ) do
289- config = update_config ( conn , config )
290- { conn , result } = conn |> execute ( config )
291-
292- case result do
293- { :input_error , msg } ->
294- conn
295- |> encode ( 400 , error_result ( msg ) , config )
287+ @ spec call ( Plug.Conn . t ( ) , map ) :: Plug.Conn . t ( ) | no_return
288+ def call ( conn , config ) do
289+ try do
290+ config = update_config ( conn , config )
291+ { conn , result } = conn |> execute ( config )
292+
293+ case result do
294+ { :input_error , msg } ->
295+ conn
296+ |> encode ( 400 , error_result ( msg ) , config )
296297
297- { :ok , % { "subscribed" => topic } } ->
298- conn
299- |> subscribe ( topic , config )
298+ { :ok , % { "subscribed" => topic } } ->
299+ conn
300+ |> subscribe ( topic , config )
300301
301- { :ok , % { data: _ } = result } ->
302- conn
303- |> encode ( 200 , result , config )
302+ { :ok , % { data: _ } = result } ->
303+ conn
304+ |> encode ( 200 , result , config )
304305
305- { :ok , % { errors: _ } = result } ->
306- conn
307- |> encode ( 200 , result , config )
306+ { :ok , % { errors: _ } = result } ->
307+ conn
308+ |> encode ( 200 , result , config )
308309
309- { :ok , result } when is_list ( result ) ->
310- conn
311- |> encode ( 200 , result , config )
310+ { :ok , result } when is_list ( result ) ->
311+ conn
312+ |> encode ( 200 , result , config )
312313
313- { :error , { :http_method , text } , _ } ->
314- conn
315- |> encode ( 405 , error_result ( text ) , config )
314+ { :error , { :http_method , text } , _ } ->
315+ conn
316+ |> encode ( 405 , error_result ( text ) , config )
316317
317- { :error , error , _ } when is_binary ( error ) ->
318- conn
319- |> encode ( 500 , error_result ( error ) , config )
318+ { :error , error , _ } when is_binary ( error ) ->
319+ conn
320+ |> encode ( 500 , error_result ( error ) , config )
321+ end
322+ catch
323+ :exit , { :timeout , _ } = _reason ->
324+ conn
325+ |> encode ( 500 , error_result ( "Timeout" ) , config )
326+ end
320327 end
321- end
322328
323329 @ doc false
324330 def update_config ( conn , config ) do
0 commit comments