def _errmsg(argname, ltd, errmsgExtra=''):
    """Construct an error message.

    argname, string, the argument name.
    ltd, string, description of the legal types.
    errmsgExtra, string, text to append to error mssage.
    Returns: string, the error message.
    """
    if errmsgExtra:
        errmsgExtra = '\n' + errmsgExtra
    return "arg '%s' must be %s%s" % (argname, ltd, errmsgExtra)