from typing import Optional
from typing import Union


def build_error(status: int, title: str, 
                detail: Optional[Union[list, dict, str]] = None) -> dict:
    """Return a dictionary describing the error.

    Schema:
    {
        'error': {
            'status': "HTTP status code"
            'title': "short title"
            'detail': "An optional string, list or dictionary with error details"
        }
    }
    """
    error = {
        'error': {
            'status': status,
            'title': title,
        }
    }
    if detail:
        error['error']['detail'] = detail
    return error