From 496048ec122e4dd501be5477bde6299778756ece Mon Sep 17 00:00:00 2001 From: Larry Kim Date: Thu, 6 Jun 2013 02:49:44 +0900 Subject: [PATCH] Add custom exception and raise InvalidInputText when 'text' is boolean on parser --- whois/error.py | 6 ++++++ whois/parser.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/whois/error.py b/whois/error.py index e69de29..127f42b 100644 --- a/whois/error.py +++ b/whois/error.py @@ -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) diff --git a/whois/parser.py b/whois/parser.py index 79e1520..2b111cc 100644 --- a/whois/parser.py +++ b/whois/parser.py @@ -46,6 +46,10 @@ class Parser(object): logging.debug("__init__: DEBUG is set to True") self.domain = unicode(domain, "utf-8").encode("idna") + + if not text: + raise error.InvalidInputText(text) + self.text = text self.whoisServer = whoisServer and whoisServer or "default"