<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_error(error: "GraphQLError") -> dict: """Format a GraphQL error Given a GraphQLError, format it according to the rules described by the "Response Format, Errors" section of the GraphQL Specification. """

    if not error:
        raise ValueError("Received null or undefined error.")
    formatted: Dict[str, Any] = dict(  # noqa: E701 (pycqa/flake8#394)
        message=error.message or "An unknown error occurred.",
        locations=error.locations,
        path=error.path,
    )
    if error.extensions:
        formatted.update(extensions=error.extensions)
    return formatted