Better error handling of no URL/Key are passed

pull/2/merge v1.12
Raphaël Vinot 2015-09-18 17:48:10 +02:00
parent 11b3470167
commit f4bf57cc46
2 changed files with 15 additions and 2 deletions

View File

@ -1,3 +1,3 @@
__version__ = '1.11'
__version__ = '1.12'
from .api import PyMISP
from .api import PyMISP, PyMISPError, NewEventError, NewAttributeError, MissingDependency, NoURL, NoKey

View File

@ -51,6 +51,14 @@ class MissingDependency(PyMISPError):
pass
class NoURL(PyMISPError):
pass
class NoKey(PyMISPError):
pass
def deprecated(func):
'''This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
@ -82,6 +90,11 @@ class PyMISP(object):
"""
def __init__(self, url, key, ssl=True, out_type='json'):
if not url:
raise NoURL('Please provide the URL of your MISP instance.')
if not key:
raise NoKey('Please provide your authorization key.')
self.root_url = url
self.key = key
self.ssl = ssl