Skip to content

Return custom error message #513

Closed
Closed
@jonatasbaldin

Description

@jonatasbaldin

Hi there!

I'd like to know the better way to raise an exception on a Mutation. For example, while trying to create a User with an email address that already exists.

if email
    user = User.objects.filter(email=email).first()

    if user:
       # ?

return CreateUser(username=username, password=password)

I know that I can raise Exception('message'), but is this the best way? Can we do it differently?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions