- "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])",
0 commit comments