def coerce_int_except(v, msg):   
    """Convert to an int, throw an exception if it isn't"""
   
    try:
        return int(v)
    except:
        raise ValueError("Bad value: '{}'; {} ".format(v,msg) )