Skip to content

Commit 2d9c33d

Browse files
committed
fix: return context data regardless of template matching result
1 parent 5f2d310 commit 2d9c33d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

errgoengine.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,19 @@ func (e *ErrgoEngine) AttachMainFS(instance fs.ReadFileFS) {
4949

5050
func (e *ErrgoEngine) Analyze(workingPath, msg string) (*CompiledErrorTemplate, *ContextData, error) {
5151
template := e.ErrorTemplates.Match(msg)
52-
if template == nil {
53-
return nil, nil, fmt.Errorf("template not found. \nMessage: %s", msg)
54-
}
5552

5653
// initial context data extraction
5754
contextData := NewContextData(e.SharedStore, workingPath)
58-
contextData.Analyzer = template.Language.AnalyzerFactory(contextData)
5955
contextData.AddVariable("message", msg)
6056
contextData.FS = e.FS
6157

58+
// return context data if template is not found
59+
if template == nil {
60+
return nil, contextData, fmt.Errorf("template not found. \nMessage: %s", msg)
61+
}
62+
63+
contextData.Analyzer = template.Language.AnalyzerFactory(contextData)
64+
6265
// extract variables from the error message
6366
contextData.AddVariables(template.ExtractVariables(msg))
6467

0 commit comments

Comments
 (0)