def METHOD_NAME(
    *, error_msg_template: str, resource_name: str, use_error_v1: bool
) -> Iterator[None]:
    """Context manager to handle ValidationError and reraise them as HTTPUnprocessableEntity error
    Arguments:
        error_msg_template -- _description_
        resource_name --
        use_error_v1 -- If True, it uses new error response
    Raises:
        web.HTTPUnprocessableEntity: (422) raised from a ValidationError
    """
    try:
        yield
    except ValidationError as err:
        details = [
            {
                "loc": ".".join(map(str, e["loc"])),
                "msg": e["msg"],
                "type": e["type"],
            }
            for e in err.errors()
        ]
        reason_msg = error_msg_template.format(
            failed=", ".join(d["loc"] for d in details)
        )
        if use_error_v1:
            # NOTE: keeps backwards compatibility until ligher error response is implemented in the entire API
            # Implements servicelib.aiohttp.rest_responses.ErrorItemType
            errors = [
                {
                    "code": e["type"],
                    "message": e["msg"],
                    "resource": resource_name,
                    "field": e["loc"],
                }
                for e in details
            ]
            error_str = json_dumps(
                {
                    "error": {
                        "status": web.HTTPUnprocessableEntity.status_code,
                        "errors": errors,
                    }
                }
            )
        else:
            # NEW proposed error for https://github.com/ITISFoundation/osparc-simcore/issues/443
            error_str = json_dumps(
                {
                    "error": {
                        "msg": reason_msg,
                        "resource": resource_name,  # optional
                        "details": details,  # optional
                    }
                }
            )
        raise web.HTTPUnprocessableEntity(  # 422
            reason=reason_msg,
            text=error_str,
            content_type=MIMETYPE_APPLICATION_JSON,
        ) from err