Skip to content

Instantly share code, notes, and snippets.

@sultaniman
Created April 28, 2019 12:43
Show Gist options
  • Save sultaniman/263f9a4f2384da753d2c8df165970c6a to your computer and use it in GitHub Desktop.
Save sultaniman/263f9a4f2384da753d2c8df165970c6a to your computer and use it in GitHub Desktop.
Standard API errors
defmodule IdpWeb.Schema.Errors do
@moduledoc """
Defines common GraphQL error responses
"""
defmacro __using__(_) do
quote do
@permission_denied {
:error,
%{
message: "Permission denied",
code: :permission_denied
}
}
@not_found {
:error,
%{
code: :not_found,
message: "Not found"
}
}
@not_authenticated {
:error,
%{
code: :not_authenticated,
message: "Not authenticated"
}
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment