NOTE: This is different than the proposed duplicates as this deals with an argument rather than a value. The behavior and applicable scenarios are essentially different.
Since you have the login in a function you can throw InvalidArgumentException.
The exception that is raised when a parameter that is not valid is passed to a method on the referenced connection to the server.
EDIT:
A better alternative would be: ArgumentException, since InvalidArgumentException
in Microsoft.SqlServer.Management.Common
namespace. Something like:
throw new ArgumentException("Unhandled value: " + value.ToString());