Skip to content

Commit 014b1ed

Browse files
committed
#49 improving exception filtering and classification
1 parent fbf96a1 commit 014b1ed

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

nodes/2.x/Journal.ByPath.dyf

+1-1
Large diffs are not rendered by default.

nodes/2.x/Journal.Exceptions.dyf

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{
1414
"ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels",
1515
"NodeType": "PythonScriptNode",
16-
"Code": "import clr\r\n\r\nclass RecordedException:\r\n\tdef __init__(self, journalLine):\r\n\t\tself.JournalLine = journalLine\r\n\t\tself.Type = \"Unknown\"\r\n\t\tself.Message = None\r\n\t\tself.Event = None\r\n\t\tself.AppName = None\r\n\t\tself.AppGUID = None\r\n\t\tself.StackTrace = None\r\n\tdef __repr__(self):\r\n\t\treturn \"RecordedException\"\r\n\r\ndef process_input(func, input):\r\n\tif isinstance(input, list): return [func(x) for x in input]\r\n\telse: return func(input)\r\n\t\r\ndef journalGetExceptions(journal):\r\n\tif journal.__repr__() == 'Journal': \r\n\t\texclines = journal.GetExceptions()\r\n\t\texcobjs = []\r\n\t\tfor line in exclines:\r\n\t\t\tnewexc = RecordedException(line)\r\n\t\t\tif line.Type == \"JournalTimeStamp\": \r\n\t\t\t\tlp1 = line.Description.split(\"ApplicationException is being thrown on behalf of the function <\",1)\r\n\t\t\t\tif len(lp1) > 1:\r\n\t\t\t\t\tnewexc.Type = \"ApplicationException\"\r\n\t\t\t\t\tnewexc.Message = lp1[0]\r\n\t\t\t\t\tlp2 = lp1[1].split(\">\",1)\r\n\t\t\t\t\tnewexc.StackTrace = lp2[0]\r\n\t\t\t\telif \"ArchiveException\" in line.Description:\r\n\t\t\t\t\tnewexc.Type = \"ArchiveException\"\r\n\t\t\t\t\tnewexc.Message = line.Description\r\n\t\t\t\telse: newexc.Message = line.Description\r\n\t\t\telif line.Type == \"JournalAPIMessage\": \r\n\t\t\t\tlp1 = line.MessageText.split(\" exception(\",1)\r\n\t\t\t\tnewexc.Type = lp1[0]\r\n\t\t\t\tif len(lp1) > 1: \r\n\t\t\t\t\tlp2 = lp1[1].split(\") was thrown from a handler of \",1)\r\n\t\t\t\t\tnewexc.Message = lp2[0]\r\n\t\t\t\t\tif len(lp2) > 1: \r\n\t\t\t\t\t\tlp3 = lp2[1].split(\"event. The API event handler was registered by application \",1)\r\n\t\t\t\t\t\tnewexc.Event = lp3[0]\r\n\t\t\t\t\t\tif len(lp3) > 1: \r\n\t\t\t\t\t\t\tlp4 = lp3[1].split(\" (\",1)\r\n\t\t\t\t\t\t\tnewexc.AppName = lp4[0]\r\n\t\t\t\t\t\t\tif len(lp4) > 1:\r\n\t\t\t\t\t\t\t\tlp5 = lp4[1].split(\")\",1)\r\n\t\t\t\t\t\t\t\tnewexc.AppGUID = lp5[0]\r\n\t\t\telif line.Type == \"JournalComment\":\r\n\t\t\t\tlp1 = line.RawText.split(\"Exception caught from managed method \",1)\r\n\t\t\t\tif len(lp1) > 1:\r\n\t\t\t\t\tlp2 = lp1[1].split(\" <\",1)\r\n\t\t\t\t\tnewexc.StackTrace = lp2[0]\r\n\t\t\t\t\tif len(lp2) > 1:\r\n\t\t\t\t\t\tlp3 = lp2[1].split(\"> <\",1)\r\n\t\t\t\t\t\tnewexc.Type = lp3[0]\r\n\t\t\t\t\t\tif len(lp3) > 1: newexc.Message = lp3[1].strip()[:-1]\r\n\t\t\t\telse: \r\n\t\t\t\t\tlp1 = line.RawText.split(\"External Command Registration Exception: \",1)\r\n\t\t\t\t\tif len(lp1) > 1:\r\n\t\t\t\t\t\tnewexc.Type = \"External Command Registration Exception\"\r\n\t\t\t\t\t\tnewexc.Message = lp1[1]\r\n\t\t\t\t\telif \"OpenStream FileException\" in line.RawText: newexc.Type = \"OpenStream FileException\"\r\n\t\t\t\t\telse: newexc.Message = line.RawText\r\n\t\t\telse: newexc.Message = line.RawText\r\n\t\t\texcobjs.append(newexc)\r\n\t\treturn excobjs\r\n\telse: return []\r\n\r\nOUT = process_input(journalGetExceptions,IN[0])",
16+
"Code": "import clr\r\n\r\nclass RecordedException:\r\n\tdef __init__(self, journalLine):\r\n\t\tself.JournalLine = journalLine\r\n\t\tself.Type = \"Unknown\"\r\n\t\tself.Message = None\r\n\t\tself.Event = None\r\n\t\tself.AppName = None\r\n\t\tself.AppGUID = None\r\n\t\tself.StackTrace = None\r\n\tdef __repr__(self):\r\n\t\treturn \"RecordedException\"\r\n\r\ndef process_input(func, input):\r\n\tif isinstance(input, list): return [func(x) for x in input]\r\n\telse: return func(input)\r\n\t\r\ndef journalGetExceptions(journal):\r\n\tif journal.__repr__() == 'Journal': \r\n\t\texclines = journal.GetExceptions()\r\n\t\texcobjs = []\r\n\t\tfor line in exclines:\r\n\t\t\tnewexc = RecordedException(line)\r\n\t\t\tif line.Type == \"JournalTimeStamp\": \r\n\t\t\t\tlp1 = line.Description.split(\"ApplicationException is being thrown on behalf of the function <\",1)\r\n\t\t\t\tif len(lp1) > 1:\r\n\t\t\t\t\tnewexc.Type = \"ApplicationException\"\r\n\t\t\t\t\tnewexc.Message = lp1[0]\r\n\t\t\t\t\tlp2 = lp1[1].split(\">\",1)\r\n\t\t\t\t\tnewexc.StackTrace = lp2[0]\r\n\t\t\t\telse:\r\n\t\t\t\t\tif \"ArchiveException\" in line.Description: newexc.Type = \"ArchiveException\"\r\n\t\t\t\t\telif line.Description.startswith(\"ExceptionCode\"): newexc.Type = \"Fatal Error\"\r\n\t\t\t\t\tnewexc.Message = line.Description\r\n\t\t\telif line.Type == \"JournalAPIMessage\": \r\n\t\t\t\tlp1 = line.MessageText.split(\" exception(\",1)\r\n\t\t\t\tnewexc.Type = lp1[0]\r\n\t\t\t\tif len(lp1) > 1: \r\n\t\t\t\t\tlp2 = lp1[1].split(\") was thrown from a handler of \",1)\r\n\t\t\t\t\tnewexc.Message = lp2[0]\r\n\t\t\t\t\tif len(lp2) > 1: \r\n\t\t\t\t\t\tlp3 = lp2[1].split(\"event. The API event handler was registered by application \",1)\r\n\t\t\t\t\t\tnewexc.Event = lp3[0]\r\n\t\t\t\t\t\tif len(lp3) > 1: \r\n\t\t\t\t\t\t\tlp4 = lp3[1].split(\" (\",1)\r\n\t\t\t\t\t\t\tnewexc.AppName = lp4[0]\r\n\t\t\t\t\t\t\tif len(lp4) > 1:\r\n\t\t\t\t\t\t\t\tlp5 = lp4[1].split(\")\",1)\r\n\t\t\t\t\t\t\t\tnewexc.AppGUID = lp5[0]\r\n\t\t\telif line.Type == \"JournalComment\":\r\n\t\t\t\tlp1 = line.RawText.split(\"Exception caught from managed method \",1)\r\n\t\t\t\tif len(lp1) > 1:\r\n\t\t\t\t\tlp2 = lp1[1].split(\" <\",1)\r\n\t\t\t\t\tnewexc.StackTrace = lp2[0]\r\n\t\t\t\t\tif len(lp2) > 1:\r\n\t\t\t\t\t\tlp3 = lp2[1].split(\"> <\",1)\r\n\t\t\t\t\t\tnewexc.Type = lp3[0]\r\n\t\t\t\t\t\tif len(lp3) > 1: newexc.Message = lp3[1].strip()[:-1]\r\n\t\t\t\telse: \r\n\t\t\t\t\tlp1 = line.RawText.split(\"External Command Registration Exception: \",1)\r\n\t\t\t\t\tif len(lp1) > 1:\r\n\t\t\t\t\t\tnewexc.Type = \"External Command Registration Exception\"\r\n\t\t\t\t\t\tnewexc.Message = lp1[1]\r\n\t\t\t\t\telif \"OpenStream FileException\" in line.RawText: newexc.Type = \"OpenStream FileException\"\r\n\t\t\t\t\telse: newexc.Message = line.RawText\r\n\t\t\telse: newexc.Message = line.RawText\r\n\t\t\texcobjs.append(newexc)\r\n\t\treturn excobjs\r\n\telse: return []\r\n\r\nOUT = process_input(journalGetExceptions,IN[0])",
1717
"Engine": "IronPython2",
1818
"VariableInputPorts": true,
1919
"Id": "9cff4ceec88a4c579476332687560f6b",

nodes/2.x/python/Journal.ByPath.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def GetExceptions(self):
3737
exlist = []
3838
exlist.extend([x for x in self.GetLinesByType('JournalTimeStamp') if "Exception" in x.Description])
3939
exlist.extend([x for x in self.GetLinesByType('JournalAPIMessage') if x.IsError and "Exception" in x.MessageText])
40-
exlist.extend([x for x in self.GetLinesByType('JournalComment') if "Exception" in x.RawText and "ExceptionPolicy" not in x.RawText and "Exception occurred" not in x.RawText])
40+
exlist.extend([x for x in self.GetLinesByType('JournalComment') if "Exception" in x.RawText and "ExceptionPolicy" not in x.RawText and "Exception occurred" not in x.RawText and "unhandledExceptionFilter" not in x.RawText])
4141
exlist.sort(key=lambda x: x.Number)
4242
return exlist
4343
def GetFirstLines(self, number):

nodes/2.x/python/Journal.Exceptions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ def journalGetExceptions(journal):
2929
newexc.Message = lp1[0]
3030
lp2 = lp1[1].split(">",1)
3131
newexc.StackTrace = lp2[0]
32-
elif "ArchiveException" in line.Description:
33-
newexc.Type = "ArchiveException"
32+
else:
33+
if "ArchiveException" in line.Description: newexc.Type = "ArchiveException"
34+
elif line.Description.startswith("ExceptionCode"): newexc.Type = "Fatal Error"
3435
newexc.Message = line.Description
35-
else: newexc.Message = line.Description
3636
elif line.Type == "JournalAPIMessage":
3737
lp1 = line.MessageText.split(" exception(",1)
3838
newexc.Type = lp1[0]

0 commit comments

Comments
 (0)