diff --git a/lib/console/graphql/exceptions/protocol.ex b/lib/console/graphql/exceptions/protocol.ex index 0aa7b9b669..372d9d0169 100644 --- a/lib/console/graphql/exceptions/protocol.ex +++ b/lib/console/graphql/exceptions/protocol.ex @@ -13,5 +13,9 @@ defimpl Console.GraphQl.Exception, for: Ecto.NoResultsError do end defimpl Console.GraphQl.Exception, for: Ecto.CastError do - def error(_), do: {400, "invalid input"} + def error(_), do: {400, "could not find resource"} +end + +defimpl Console.GraphQl.Exception, for: Ecto.Query.CastError do + def error(_), do: {404, "could not find resource"} end diff --git a/lib/console/graphql/middleware/safe_resolution.ex b/lib/console/graphql/middleware/safe_resolution.ex index 5f8ab9ba84..c7f9611ab3 100644 --- a/lib/console/graphql/middleware/safe_resolution.ex +++ b/lib/console/graphql/middleware/safe_resolution.ex @@ -29,9 +29,11 @@ defmodule Console.Middleware.SafeResolution do Resolution.call(resolution, resolver) rescue exception -> - {_, msg} = Console.GraphQl.Exception.error(exception) - error = Exception.format(:error, exception, __STACKTRACE__) - Logger.error(error) + {code, msg} = Console.GraphQl.Exception.error(exception) + if code >= 500 do + error = Exception.format(:error, exception, __STACKTRACE__) + Logger.error(error) + end Resolution.put_result(resolution, {:error, msg}) end end