Throw exceptions for wrong inputs