Question: A particular definition in the python reference library (sub-section: string literals) is making me feel a lot of uncertainty.

`shortstringchar ::= <any source character except "\" or newline or the quote>`

What is meant by `newline` here? It definitely couldn't be `\n`, that's not just one source character, but two: `\` and `n`. Right?

I've been told that it's an invisible character, characterized by the split of a string into two physical lines when you press "enter/return" on your keyboard. For example, 

1 `hello`  

2 `world`

there is a newline character between `hello` and `world`.

How true is this? Could I get some more detail and maybe some source material that talks about the newline character?

Answer: 
Create a custom error type
==========================

```py
import graphene
from graphene_django.utils import camelize

class ErrorType(graphene.Scalar):
    @staticmethod
    def serialize(errors):
        if isinstance(errors, dict):
            if errors.get("__all__", False):
                errors["non_field_errors"] = errors.pop("__all__")
            return camelize(errors)
        raise Exception("`errors` should be dict!")

```

Add it to your mutations
========================

```py
class MyMutation(graphene.Mutation):

    # add the custom error type
    errors = graphene.Field(ErrorType)

    form = SomeForm

    @classmethod
    def mutate(cls, root, info, **kwargs):
        f = cls.form(kwargs)
        if f.is_valid():
            pass
        else:
            # pass the form error to your custom error type
            return cls(errors=f.errors.get_json_data())

```

Example
=======

[django-graphql-auth](https://github.com/PedroBern/django-graphql-auth) uses a similar error type, and it works like this, for example for registration:

```
mutation {
  register(
    email:"skywalker@email.com",
    username:"skywalker",
    password1: "123456",
    password2:"123"
  ) {
    success,
    errors,
    token,
    refreshToken
  }
}

```

should return:

```
{
  "data": {
    "register": {
      "success": false,
      "errors": {
        "password2": [
          {
            "message": "The two password fields didn’t match.",
            "code": "password_mismatch"
          }
        ]
      },
      "token": null,
      "refreshToken": null
    }
  }
}

```
My Django form errors types, for example:

```
from graphene.utils.str_converters import to_camel_case

class DjangoFormError(graphene.ObjectType):
    field = graphene.String()
    message = graphene.String()

    @classmethod
    def list_from_errors_dict(cls: Type[T], django_form_errors: dict) -> List[T]:
        return [
            cls(field=to_camel_case(field), message=' '.join(messages))
            for field, messages in django_form_errors.items()
        ]

class DjangoFormErrorsByIdx(graphene.ObjectType):
    form_idx = graphene.Int()
    errors = graphene.List(DjangoFormError)

    @classmethod
    def list_from_idx_dict(cls: Type[T], errors_by_idx_dict: dict) -> List[T]:
        return [
            cls(
                form_idx=idx,
                errors=DjangoFormError.list_from_errors_dict(django_form_errors),
            )
            for idx, django_form_errors in errors_by_idx_dict.items()
        ]   

# ...
# in mutation
if not django_form.is_valid():
    form_errors = DjangoFormError.list_from_errors_dict(
        django_form.errors
    )

```