Skip to content

Commit 08d9586

Browse files
committed
#66 solved for 2.x plus some additional refinements
1 parent e1eec88 commit 08d9586

File tree

2 files changed

+34
-18
lines changed

2 files changed

+34
-18
lines changed

nodes/2.x/Journal.Exceptions.dyf

+3-3
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\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])",
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\taddnewexc = True\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\tif line.MessageText.startswith(\"An external service execution throws\"):\r\n\t\t\t\t\taddnewexc = False\r\n\t\t\t\t\tlp1 = line.MessageText.split(\":\")\r\n\t\t\t\t\texcobjs[-1].Message = excobjs[-1].Message + \" \" + lp1[0]\r\n\t\t\t\t\tif len(lp1) > 1:\r\n\t\t\t\t\t\tlp2 = lp1[1].split(\"; \")\r\n\t\t\t\t\t\texcobjs[-1].AppName = lp2[0].replace(\" Name(\",\"\").replace(\")\",\"\")\r\n\t\t\t\t\t\tif len(lp2) > 3: excobjs[-1].AppGUID = lp2[2] + \", \" + lp2[3]\r\n\t\t\t\telse:\r\n\t\t\t\t\tlp1 = line.MessageText.split(\" exception(\",1)\r\n\t\t\t\t\tnewexc.Type = lp1[0]\r\n\t\t\t\t\tif len(lp1) > 1: \r\n\t\t\t\t\t\tlp2 = lp1[1].split(\") was thrown from a handler of \",1)\r\n\t\t\t\t\t\tnewexc.Message = lp2[0]\r\n\t\t\t\t\t\tif len(lp2) > 1: \r\n\t\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\t\tnewexc.Event = lp3[0]\r\n\t\t\t\t\t\t\tif len(lp3) > 1: \r\n\t\t\t\t\t\t\t\tlp4 = lp3[1].split(\" (\",1)\r\n\t\t\t\t\t\t\t\tnewexc.AppName = lp4[0]\r\n\t\t\t\t\t\t\t\tif len(lp4) > 1:\r\n\t\t\t\t\t\t\t\t\tlp5 = lp4[1].split(\")\",1)\r\n\t\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\tlp2 = line.RawText.split(\":< \")\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\telif \"exceptionsInOnOpenDocument\" in line.RawText:\r\n\t\t\t\t\t\taddnewexc = False\r\n\t\t\t\t\t\tlp3 = line.RawText.split(\"<<\")\r\n\t\t\t\t\t\tif len(lp3) > 1: excobjs[-1].Message = excobjs[-1].Message + \" \" + lp3[1]\r\n\t\t\t\t\telif len(lp2) > 1: newexc.Message = lp2[1]\r\n\t\t\t\t\telse: newexc.Message = line.RawText\r\n\t\t\telse: newexc.Message = line.RawText\r\n\t\t\tif addnewexc: excobjs.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",
@@ -160,8 +160,8 @@
160160
}
161161
],
162162
"Annotations": [],
163-
"X": 476.0,
164-
"Y": 308.0,
163+
"X": 119.0,
164+
"Y": 331.0,
165165
"Zoom": 1.0
166166
}
167167
}

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

+31-15
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def journalGetExceptions(journal):
2222
excobjs = []
2323
for line in exclines:
2424
newexc = RecordedException(line)
25+
addnewexc = True
2526
if line.Type == "JournalTimeStamp":
2627
lp1 = line.Description.split("ApplicationException is being thrown on behalf of the function <",1)
2728
if len(lp1) > 1:
@@ -34,20 +35,29 @@ def journalGetExceptions(journal):
3435
elif line.Description.startswith("ExceptionCode"): newexc.Type = "Fatal Error"
3536
newexc.Message = line.Description
3637
elif line.Type == "JournalAPIMessage":
37-
lp1 = line.MessageText.split(" exception(",1)
38-
newexc.Type = lp1[0]
39-
if len(lp1) > 1:
40-
lp2 = lp1[1].split(") was thrown from a handler of ",1)
41-
newexc.Message = lp2[0]
42-
if len(lp2) > 1:
43-
lp3 = lp2[1].split("event. The API event handler was registered by application ",1)
44-
newexc.Event = lp3[0]
45-
if len(lp3) > 1:
46-
lp4 = lp3[1].split(" (",1)
47-
newexc.AppName = lp4[0]
48-
if len(lp4) > 1:
49-
lp5 = lp4[1].split(")",1)
50-
newexc.AppGUID = lp5[0]
38+
if line.MessageText.startswith("An external service execution throws"):
39+
addnewexc = False
40+
lp1 = line.MessageText.split(":")
41+
excobjs[-1].Message = excobjs[-1].Message + " " + lp1[0]
42+
if len(lp1) > 1:
43+
lp2 = lp1[1].split("; ")
44+
excobjs[-1].AppName = lp2[0].replace(" Name(","").replace(")","")
45+
if len(lp2) > 3: excobjs[-1].AppGUID = lp2[2] + ", " + lp2[3]
46+
else:
47+
lp1 = line.MessageText.split(" exception(",1)
48+
newexc.Type = lp1[0]
49+
if len(lp1) > 1:
50+
lp2 = lp1[1].split(") was thrown from a handler of ",1)
51+
newexc.Message = lp2[0]
52+
if len(lp2) > 1:
53+
lp3 = lp2[1].split("event. The API event handler was registered by application ",1)
54+
newexc.Event = lp3[0]
55+
if len(lp3) > 1:
56+
lp4 = lp3[1].split(" (",1)
57+
newexc.AppName = lp4[0]
58+
if len(lp4) > 1:
59+
lp5 = lp4[1].split(")",1)
60+
newexc.AppGUID = lp5[0]
5161
elif line.Type == "JournalComment":
5262
lp1 = line.RawText.split("Exception caught from managed method ",1)
5363
if len(lp1) > 1:
@@ -59,13 +69,19 @@ def journalGetExceptions(journal):
5969
if len(lp3) > 1: newexc.Message = lp3[1].strip()[:-1]
6070
else:
6171
lp1 = line.RawText.split("External Command Registration Exception: ",1)
72+
lp2 = line.RawText.split(":< ")
6273
if len(lp1) > 1:
6374
newexc.Type = "External Command Registration Exception"
6475
newexc.Message = lp1[1]
6576
elif "OpenStream FileException" in line.RawText: newexc.Type = "OpenStream FileException"
77+
elif "exceptionsInOnOpenDocument" in line.RawText:
78+
addnewexc = False
79+
lp3 = line.RawText.split("<<")
80+
if len(lp3) > 1: excobjs[-1].Message = excobjs[-1].Message + " " + lp3[1]
81+
elif len(lp2) > 1: newexc.Message = lp2[1]
6682
else: newexc.Message = line.RawText
6783
else: newexc.Message = line.RawText
68-
excobjs.append(newexc)
84+
if addnewexc: excobjs.append(newexc)
6985
return excobjs
7086
else: return []
7187

0 commit comments

Comments
 (0)