File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ def newegg_url(match):
9393
9494
9595@hook .command ()
96- def newegg (text ):
96+ def newegg (text , admin_log , reply ):
9797 """<item name> - searches newegg.com for <item name>"""
9898
9999 # form the search request
@@ -121,8 +121,16 @@ def newegg(text):
121121
122122 r = request .json ()
123123
124- if r .get ("Description" , False ):
125- return "Newegg Error: {Description} (\x02 {Code}\x02 )" .format (** r )
124+ if not request .ok :
125+ if r .get ("Message" ):
126+ msg = "{ExceptionMessage}\n {ExceptionType}\n {StackTrace}" .format (** r ).replace ("\r " , "" )
127+ url = web .paste (msg )
128+ admin_log ("Newegg API Error: {ExceptionType}: {url}" .format (url = url , ** r ))
129+ return "Newegg Error: {Message} (\x02 {code}\x02 )" .format (code = request .status_code , ** r )
130+ else :
131+ reply ("Unknown error occurred." )
132+ request .raise_for_status ()
133+ return
126134
127135 # get the first result
128136 if r ["ProductListItems" ]:
You can’t perform that action at this time.
0 commit comments