Add custom exception and raise InvalidInputText when 'text' is boolean on parser

This commit is contained in:
Larry Kim 2013-06-06 02:49:44 +09:00
parent 7aea99b3f9
commit 496048ec12
2 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
class InvalidInputText(Exception):
def __init__(self, text):
self.message = "Invalid input text: %s"%(text)
Exception.__init__(self, self.message)

View File

@ -46,6 +46,10 @@ class Parser(object):
logging.debug("__init__: DEBUG is set to True") logging.debug("__init__: DEBUG is set to True")
self.domain = unicode(domain, "utf-8").encode("idna") self.domain = unicode(domain, "utf-8").encode("idna")
if not text:
raise error.InvalidInputText(text)
self.text = text self.text = text
self.whoisServer = whoisServer and whoisServer or "default" self.whoisServer = whoisServer and whoisServer or "default"