Improve handling for exceptions, output more information so we can find and fix problems.

This commit is contained in:
Ebag333
2017-02-12 13:09:26 -08:00
parent e7a5cb4b1d
commit 35e330f574
12 changed files with 50 additions and 33 deletions

View File

@@ -49,8 +49,9 @@ try:
config.gamedata_version = gamedata_session.execute(
"SELECT `field_value` FROM `metadata` WHERE `field_name` LIKE 'client_build'"
).fetchone()[0]
except:
except Exception as e:
pyfalog.warning("Missing gamedata version.")
pyfalog.critical(e)
config.gamedata_version = None
saveddata_connectionstring = config.saveddata_connectionstring

View File

@@ -68,9 +68,9 @@ class FitDpsGraph(Graph):
bonus = values[i]
val *= 1 + (bonus - 1) * exp(- i ** 2 / 7.1289)
data[attr] = val
except:
pyfalog.warning("Caught exception in calcDPS.")
pass
except Exception as e:
pyfalog.critical("Caught exception in calcDPS.")
pyfalog.critical(e)
for mod in fit.modules:
dps, _ = mod.damageStats(fit.targetResists)

View File

@@ -639,6 +639,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
effect.handler(fit, self, chargeContext, effect=effect)
except:
effect.handler(fit, self, chargeContext)
pyfalog.debug("Applying effect handler for charge without effect.")
if self.item:
if self.state >= State.OVERHEATED:
@@ -662,6 +663,7 @@ class Module(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut):
effect.handler(fit, self, context, effect=effect)
except:
effect.handler(fit, self, context)
pyfalog.debug("Applying effect handler without effect")
@property
def cycleTime(self):

View File

@@ -18,6 +18,9 @@
# ===============================================================================
import re
from logbook import Logger
pyfalog = Logger(__name__)
class TargetResists(object):
@@ -43,7 +46,7 @@ class TargetResists(object):
type, data = line.rsplit('=', 1)
type, data = type.strip(), data.split(',')
except:
# Data isn't in correct format, continue to next line
pyfalog.warning("Data isn't in correct format, continue to next line.")
continue
if type != "TargetResists":
@@ -59,6 +62,7 @@ class TargetResists(object):
assert 0 <= val <= 100
fields["%sAmount" % cls.DAMAGE_TYPES[index]] = val / 100
except:
pyfalog.warning("Caught unhandled exception in import patterns.")
continue
if len(fields) == 4: # Avoid possible blank lines

View File

@@ -61,9 +61,9 @@ class FitSpawner(gui.multiSwitch.TabSpawner):
self.multiSwitch.SetSelection(index)
wx.PostEvent(self.mainFrame, GE.FitChanged(fitID=event.fitID))
break
except:
pyfalog.warning("Caught exception in fitSelected")
pass
except Exception as e:
pyfalog.critical("Caught exception in fitSelected")
pyfalog.critical(e)
if count < 0:
startup = getattr(event, "startup", False) # see OpenFitsThread in gui.mainFrame
sFit = Fit.getInstance()
@@ -638,15 +638,17 @@ class FittingView(d.Display):
if 'wxMac' in wx.PlatformInfo:
try:
self.MakeSnapshot()
except:
pyfalog.warning("Failed to make snapshot")
except Exception as e:
pyfalog.critical("Failed to make snapshot")
pyfalog.critical(e)
def OnShow(self, event):
if event.GetShow():
try:
self.MakeSnapshot()
except:
pyfalog.warning("Failed to make snapshot")
except Exception as e:
pyfalog.critical("Failed to make snapshot")
pyfalog.critical(e)
event.Skip()
def Snapshot(self):
@@ -671,8 +673,9 @@ class FittingView(d.Display):
sFit = Fit.getInstance()
try:
fit = sFit.getFit(self.activeFitID)
except:
pyfalog.warning("Failed to get fit")
except Exception as e:
pyfalog.critical("Failed to get fit")
pyfalog.critical(e)
if fit is None:
return

View File

@@ -114,10 +114,10 @@ class CharacterSelection(wx.Panel):
if charName:
try:
sChar.apiFetch(self.getActiveCharacter(), charName)
except:
except Exception as e:
# can we do a popup, notifying user of API error?
pyfalog.error("API fetch error")
pass
pyfalog.error(e)
self.refreshCharacterList()
def charChanged(self, event):

View File

@@ -1095,9 +1095,9 @@ class PFTabsContainer(wx.Panel):
self.previewTab = tab
self.previewTimer.Start(500, True)
break
except:
pyfalog.warning("Exception caught in CheckTabPreview.")
pass
except Exception as e:
pyfalog.critical("Exception caught in CheckTabPreview.")
pyfalog.critical(e)
def CheckAddHighlighted(self, x, y):
"""

View File

@@ -415,9 +415,9 @@ class FittingsTreeView(wx.Panel):
cargo = Cargo(getItem(item['type']['id']))
cargo.amount = item['quantity']
list.append(cargo)
except:
pyfalog.error("Exception caught in displayFit")
pass
except Exception as e:
pyfalog.critical("Exception caught in displayFit")
pyfalog.critical(e)
self.parent.fitView.fitSelection = selection
self.parent.fitView.update(list)

View File

@@ -244,6 +244,7 @@ class GraphFrame(wx.Frame):
self.subplot.plot(x, y)
legend.append(fit.name)
except:
pyfalog.warning("Invalid values in '{0}'", fit.name)
self.SetStatusText("Invalid values in '%s'" % fit.name)
self.canvas.draw()
return

View File

@@ -187,8 +187,9 @@ class MarketTree(wx.TreeCtrl):
iconId = self.addImage(sMkt.getIconByMarketGroup(childMktGrp))
try:
childId = self.AppendItem(root, childMktGrp.name, iconId, data=wx.TreeItemData(childMktGrp.ID))
except:
except Exception as e:
pyfalog.debug("Error appending item.")
pyfalog.debug(e)
continue
if sMkt.marketGroupHasTypesCheck(childMktGrp) is False:
self.AppendItem(childId, "dummy")

View File

@@ -73,13 +73,15 @@ class ShipBrowserWorkerThread(threading.Thread):
cache[id_] = set_
wx.CallAfter(callback, (id_, set_))
except:
pyfalog.debug("Callback failed.")
except Exception as e:
pyfalog.critical("Callback failed.")
pyfalog.critical(e)
finally:
try:
queue.task_done()
except:
pyfalog.debug("Queue task done failed.")
except Exception as e:
pyfalog.critical("Queue task done failed.")
pyfalog.critical(e)
class PriceWorkerThread(threading.Thread):
@@ -835,8 +837,9 @@ class Market(object):
def cb():
try:
callback(requests)
except Exception:
pyfalog.debug("Callback failed.")
except Exception as e:
pyfalog.critical("Callback failed.")
pyfalog.critical(e)
eos.db.commit()
self.priceWorkerThread.trigger(requests, cb)
@@ -851,8 +854,9 @@ class Market(object):
def cb():
try:
callback(item)
except:
pyfalog.debug("Callback failed.")
except Exception as e:
pyfalog.critical("Callback failed.")
pyfalog.critical(e)
self.priceWorkerThread.setToWait(item.ID, cb)

View File

@@ -166,8 +166,9 @@ class Port(object):
fits += fitsImport
except xml.parsers.expat.ExpatError:
return False, "Malformed XML in %s" % path
except Exception:
pyfalog.exception("Unknown exception processing: %s", path)
except Exception as e:
pyfalog.critical("Unknown exception processing: %s", path)
pyfalog.critical(e)
return False, "Unknown Error while processing %s" % path
IDs = []