Added a new function to get the IP

Also added an exception for testing purposes