class Err(Exception):
"""nicovideoで発生したエラーは全部これ。"""
+class InetErr(Err):
+ """ネット接続で問題が発生した時"""
+ def __init__(self, message):
+ self.message = message
+
+ def __str__(self):
+ return "接続エラー: {}".format(self.message)
+
class HttpErr(Err):
"""HTTPサーバーから帰ってきたステータスコードが200じゃない時"""
def __init__(self, code, message):
self.code = code
self.message = message
+ def __str__(self):
+ return "HTTPエラーコード:{}:{}".format(self.code, self.message)
+
class InterpretErr(Err):
"""構文解析で発生したエラー"""
def __init__(self, what, where="", why=""):
self.where = where
self.why = why
+ def __str__(self):
+ return "{}:構文解析エラー in {}:{}". \
+ format(self.what, self.where, self.why)
+
class NotFound(Err):
"""動画がなかった時などのエラー"""
def __init__(self, movieid, code="unknown"):
self.movieid = movieid
self.code = code
+ def __str__(self):
+ return "id:{}の動画は無いみたいです。code:{}". \
+ format(self.movieid, self.code)
+
class ApiUpdated(Err):
"""APIの返す値が想定外だった場合(迷ったらこれ)"""
def __init__(self, reason):
self.reason = reason
+
+ def __str__(self):
+ return "ニコニコからの返答が想定外です:{}".format(self.reason)