I think it partially depends on the context of the method/application. IMO, I feel you should consider the implication of what should happen if the method returns nil, not just handling it for sake of handling it.
If this was for an API, I would expect that a 404 exception would get returned to the user saying like "hey this user doesn't exist".
However that logic doesn't have to live within this method. Having this method return Nil | User is perfectly fine; where the check can happen higher up in the process.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think it partially depends on the context of the method/application. IMO, I feel you should consider the implication of what should happen if the method returns nil, not just handling it for sake of handling it.
If this was for an API, I would expect that a 404 exception would get returned to the user saying like "hey this user doesn't exist".
However that logic doesn't have to live within this method. Having this method return
Nil | User
is perfectly fine; where the check can happen higher up in the process.