Avoid exception throwing

Since uniqid() is based on the current time in microseconds, you can loop until the time changes instead of throwing an exception