You should use user_error here. A legitimate programming error shouldn't raise this, only user-initiated errors.
You also need to handle the 'false' case, or are we dropping that from the API?