def can_open_file(gcode_filepath):
    """
    check whether a given filepath can be opened. If the filepath throws an error, False is returned. If the file can
    be opened, True is returned.
    """
    if isinstance(gcode_filepath, str):  # if gcode_filepath is a string
        try:  # try opening file
            with open(gcode_filepath, 'r'):
                pass
        except IOError:  # if an error is thrown, return False
            return False
        else:  # if an error isn't thrown, return true
            return True
    else:  # gcode_filepath is not a string, return false
        return False