OSDN Git Service
(root)
/
pynv
/
pylib-nicovideo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bc9a91a
)
例外Class追加。すべてのクラスに__str__メソッド追加
author
dyknon
<dyknon@users.sourceforge.jp>
Tue, 1 Apr 2014 07:17:51 +0000
(16:17 +0900)
committer
dyknon
<dyknon@users.sourceforge.jp>
Tue, 1 Apr 2014 07:17:51 +0000
(16:17 +0900)
nicovideo/err.py
patch
|
blob
|
history
diff --git
a/nicovideo/err.py
b/nicovideo/err.py
index
8db419f
..
b0b0d17
100644
(file)
--- a/
nicovideo/err.py
+++ b/
nicovideo/err.py
@@
-20,12
+20,23
@@
class Err(Exception):
"""nicovideoで発生したエラーは全部これ。"""
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
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=""):
class InterpretErr(Err):
"""構文解析で発生したエラー"""
def __init__(self, what, where="", why=""):
@@
-33,13
+44,24
@@
class InterpretErr(Err):
self.where = where
self.why = 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
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
class ApiUpdated(Err):
"""APIの返す値が想定外だった場合(迷ったらこれ)"""
def __init__(self, reason):
self.reason = reason
+
+ def __str__(self):
+ return "ニコニコからの返答が想定外です:{}".format(self.reason)