Skip to content

Commit 2ec5ba9

Browse files
fix: add indication of in which query an exception was thrown
1 parent fa2ab72 commit 2ec5ba9

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

CodeGenerator/Generators/QueriesGen.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,22 @@ private MemberDeclarationSyntax AddMethodDeclaration(Query query)
183183
var argInterface = ClassMember.Args.Name(query.Name);
184184
var returnInterface = ClassMember.Row.Name(query.Name);
185185

186-
return query.Cmd switch
186+
try
187187
{
188-
":exec" => ((IExec)dbDriver).ExecDeclare(queryTextConstant, argInterface, query),
189-
":one" => ((IOne)dbDriver).OneDeclare(queryTextConstant, argInterface, returnInterface, query),
190-
":many" => ((IMany)dbDriver).ManyDeclare(queryTextConstant, argInterface, returnInterface, query),
191-
":execrows" => ((IExecRows)dbDriver).ExecRowsDeclare(queryTextConstant, argInterface, query),
192-
":execlastid" => ((IExecLastId)dbDriver).ExecLastIdDeclare(queryTextConstant, argInterface, query),
193-
":copyfrom" => ((ICopyFrom)dbDriver).CopyFromDeclare(queryTextConstant, argInterface, query),
194-
_ => throw new NotSupportedException($"{query.Cmd} is not supported")
195-
};
188+
return query.Cmd switch
189+
{
190+
":exec" => ((IExec)dbDriver).ExecDeclare(queryTextConstant, argInterface, query),
191+
":one" => ((IOne)dbDriver).OneDeclare(queryTextConstant, argInterface, returnInterface, query),
192+
":many" => ((IMany)dbDriver).ManyDeclare(queryTextConstant, argInterface, returnInterface, query),
193+
":execrows" => ((IExecRows)dbDriver).ExecRowsDeclare(queryTextConstant, argInterface, query),
194+
":execlastid" => ((IExecLastId)dbDriver).ExecLastIdDeclare(queryTextConstant, argInterface, query),
195+
":copyfrom" => ((ICopyFrom)dbDriver).CopyFromDeclare(queryTextConstant, argInterface, query),
196+
_ => throw new NotSupportedException($"{query.Cmd} is not supported")
197+
};
198+
}
199+
catch (Exception e)
200+
{
201+
throw new SystemException($"Failed to add method declaration for query: {query.Name}", e);
202+
}
196203
}
197204
}

0 commit comments

Comments
 (0)