{"record":{"id":"bfb3144a0ff1f7d3","repo":"SubtitleEdit/subtitleedit","slug":"parse-error-in-event-i-1-ex-message","errorCode":null,"errorMessage":"Parse error in event #{i + 1}: {ex.Message}","messagePattern":"Parse error in event #(.+?): (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/libse/SubtitleFormats/ClqttJson.cs","lineNumber":172,"sourceCode":"                            }\n\n                            subText = subText.Replace(\"\\r\\n\", Environment.NewLine).Replace(\"\\n\", Environment.NewLine);\n                            subText = subTextPrefix + Json.DecodeJsonText(subText);\n\n                            var p = new Paragraph(subText, FramesToMilliseconds(start, frameRate), FramesToMilliseconds(end, frameRate));\n                            p.Region = region;\n\n                            if (annotations.Count > 0)\n                            {\n                                p.Bookmark = String.Join(Environment.NewLine + Environment.NewLine, annotations);\n                            }\n\n                            subtitle.Paragraphs.Add(p);\n                        }\n                    }\n                    catch (Exception ex)\n                    {\n                        throw new InvalidOperationException($\"Parse error in event #{i + 1}: {ex.Message}\", ex);\n                    }\n                }\n            }\n            else\n            {\n                throw new InvalidOperationException($\"Element 'events' not found.\");\n            }\n\n            subtitle.Renumber();\n        }\n    }\n}\n","sourceCodeStart":154,"sourceCodeEnd":185,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libse/SubtitleFormats/ClqttJson.cs#L154-L185","documentation":"A catch-all wrapper thrown by ClqttJson.LoadSubtitle when any exception escapes the per-event try block (the outer event loop). The inner exception's message is prefixed with the 1-based event index, so the offending event can be located. It covers JSON field access, start/end frame parsing, region detection, and annotation handling that is not already caught by the inner style handler.","triggerScenarios":"Any unhandled exception while processing a single CLQTT event: a missing 'start'/'end'/'txt' field, a non-numeric frame value, a null annotation, or a JSON structure that deviates from expectations. The error message embeds ex.Message so the root cause is visible.","commonSituations":"A partially-valid CLQTT file where most events are fine but one is malformed; files truncated mid-stream; schema drift between producer and this importer.","solutions":["Read the embedded ex.Message in the thrown error to identify the specific field/operation that failed.","Open the .clqtt file, jump to event #{i+1}, and fix the noted field (e.g. add a missing start/end/txt).","Remove the broken event if it is non-essential, then re-import.","Re-export the file from the source tool."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate required fields exist before importing\nvar start = parser.GetFirstObject(eventJson, \"start\");\nvar end = parser.GetFirstObject(eventJson, \"end\");\nvar txt = parser.GetFirstObject(eventJson, \"txt\");\nif (string.IsNullOrEmpty(start) || string.IsNullOrEmpty(end) || string.IsNullOrEmpty(txt))\n{\n    // skip incomplete event\n    continue;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    new ClqttJson().LoadSubtitle(sub, lines, fileName);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Parse error in event\"))\n{\n    // ex.Message embeds the 1-based event index and inner cause\n    logger.Error(ex, \"CLQTT event parse failed\");\n}","preventionTips":["Pre-scan events for missing start/end/txt fields.","Reject truncated CLQTT files before import.","Keep the producer and importer versions aligned."],"tags":["subtitle-format","clqtt","json","event","wrapper"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}