def _get_error_details(
    data: Union[List, Dict, "ErrorDetail"],
    default_code: Optional[Union[str, int]] = None,
) -> Union[List["ErrorDetail"], "ErrorDetail", Dict[Any, "ErrorDetail"]]:
    """
    Descend into a nested data structure, forcing any
    lazy translation strings or strings into `ErrorDetail`.
    """
    if isinstance(data, list):
        ret = [_get_error_details(item, default_code) for item in data]
        return ret
    elif isinstance(data, dict):
        ret = {
            key: _get_error_details(value, default_code) for key, value in data.items()
        }
        return ret

    text = force_str(data)
    code = getattr(data, "code", default_code)
    return ErrorDetail(text, code)

    Descend into a nested data structure, forcing any
    lazy translation strings or strings into `ErrorDetail`.
    
ninja_extra/exceptions.py