How to use the tartiflette.types.exceptions.tartiflette.TartifletteError function in tartiflette

To help you get started, we’ve selected a few tartiflette examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tartiflette / tartiflette / tests / unit / parser / nodes / test_node_field.py View on Github external
            TartifletteError("ATartifletteError"),
            ["ATartifletteError"],
            [type(None)],
        ),
        (TypeError("ATypeError"), ["ATypeError"], [TypeError]),
        (
            MultipleException(
                exceptions=[
                    TartifletteError("ATartifletteError"),
                    TypeError("ATypeError"),
                ]
            ),
            ["ATartifletteError", "ATypeError"],
            [type(None), TypeError],
        ),
    ],
)
github tartiflette / tartiflette / tartiflette / utils / errors.py View on Github external
:param extensions: Extensions dict to add to the error.
    :type message: str
    :type nodes: Union[Node, List[Node]]
    :type path: Optional[List[str]]
    :type original_error: Optional[Exception]
    :type extensions: Optional[Dict[str, Any]]
    :return: a TartifletteError with locations
    :rtype: TartifletteError
    """
    if not isinstance(nodes, list):
        nodes = [nodes]

    if isinstance(path, Path):
        path = path.as_list()

    return TartifletteError(
        message,
        locations=[node.location for node in nodes],
        path=path,
        original_error=original_error,
        extensions=extensions,
    )
github tartiflette / tartiflette / tartiflette / utils / errors.py View on Github external
) -> Union["TartifletteError", Exception]:
    """
    Converts the raw exception into a TartifletteError if its not coercible or
    returns the raw exception if coercible.
    :param raw_exception: the raw exception to be treated
    :param message: message replacing the raw exception message when it's not
    coercible
    :type raw_exception: Exception
    :type message: Optional[str]
    :return: a coercible exception
    :rtype: Union["TartifletteError", Exception]
    """
    return (
        raw_exception
        if is_coercible_exception(raw_exception)
        else TartifletteError(
            message or str(raw_exception), original_error=raw_exception
        )
github tartiflette / tartiflette / tartiflette / types / exceptions / tartiflette.py View on Github external
pass


class UnknownDirectiveDefinition(TartifletteError):
    pass


class UnknownScalarDefinition(TartifletteError):
    pass


class UnknownFieldDefinition(TartifletteError):
    pass


class UnknownTypeDefinition(TartifletteError):
    pass


class MissingImplementation(ImproperlyConfigured):
    pass


class RedefinedImplementation(TartifletteError):
    pass


class CoercionError(TartifletteError):
    pass
github tartiflette / tartiflette / tartiflette / parser / nodes / field.py View on Github external
execution_context: ExecutionContext,
    raw_exception: Union[Exception, MultipleException],
    path: Union[str, List[str]],
    location: "Location",
) -> None:
    exceptions = (
        raw_exception.exceptions
        if isinstance(raw_exception, MultipleException)
        else [raw_exception]
    )

    for exception in exceptions:
        gql_error = (
            exception
            if is_coercible_exception(exception)
            else TartifletteError(
                str(exception), path, [location], original_error=exception
            )
        )

        gql_error.coerce_value = partial(
            gql_error.coerce_value, path=path, locations=[location]
        )

        execution_context.add_error(gql_error)
github tartiflette / tartiflette / tartiflette / types / exceptions / tartiflette.py View on Github external
pass


class UnknownFieldDefinition(TartifletteError):
    pass


class UnknownTypeDefinition(TartifletteError):
    pass


class MissingImplementation(ImproperlyConfigured):
    pass


class RedefinedImplementation(TartifletteError):
    pass


class CoercionError(TartifletteError):
    pass
github tartiflette / tartiflette / tartiflette / parser / nodes / field.py View on Github external
async def create_source_event_stream(
        self,
        execution_ctx: ExecutionContext,
        request_ctx: Optional[Dict[str, Any]],
        parent_result: Optional[Any] = None,
    ):
        if not self.subscribe:
            raise TartifletteError(
                "Can't execute a subscription query on a field which doesn't "
                "provide a source event stream with < @Subscription >."
            )

        info = Info(
            query_field=self,
            schema_field=self.field_executor.schema_field,
            schema=self.schema,
            path=self.path,
            location=self.location,
            execution_ctx=execution_ctx,
        )

        return self.subscribe(
            parent_result,
            await coerce_arguments(
github tartiflette / tartiflette / tartiflette / types / exceptions / tartiflette.py View on Github external
pass


class NonAwaitableResolver(ImproperlyConfigured):
    pass


class NonAsyncGeneratorSubscription(ImproperlyConfigured):
    pass


class NotSubscriptionField(ImproperlyConfigured):
    pass


class UnknownSchemaFieldResolver(TartifletteError):
    pass


class UnknownDirectiveDefinition(TartifletteError):
    pass


class UnknownScalarDefinition(TartifletteError):
    pass


class UnknownFieldDefinition(TartifletteError):
    pass


class UnknownTypeDefinition(TartifletteError):
github tartiflette / tartiflette / tartiflette / types / exceptions / tartiflette.py View on Github external
:type other: MultipleException
        :return: a new MultipleException containing both exception list
        :rtype: MultipleException
        """
        return MultipleException(self.exceptions + other.exceptions)


class ImproperlyConfigured(TartifletteError):
    pass


class InvalidType(TartifletteError):
    pass


class GraphQLSchemaError(TartifletteError):
    pass


class GraphQLSyntaxError(TartifletteError):
    pass


class NonCallable(ImproperlyConfigured):
    pass


class NonCoroutine(ImproperlyConfigured):
    pass


class NonAwaitableResolver(ImproperlyConfigured):