@@ -232,3 +232,32 @@ func TestFormatterErrorWithProcName(t *testing.T) {
232232 assert .Contains (t , output , "Line 10" )
233233 assert .Contains (t , output , "Error raised from stored procedure." )
234234}
235+
236+ func TestFormatterErrorWithProcNameRawMode (t * testing.T ) {
237+ // Test that errors with ProcName in raw mode skip header but still print message
238+ vars := InitializeVariables (false )
239+ errBuf := new (strings.Builder )
240+
241+ // Create formatter with rawErrors = true
242+ f := NewSQLCmdDefaultFormatter (false , ControlIgnore , true ).(* sqlCmdFormatterType )
243+ f .BeginBatch ("" , vars , new (strings.Builder ), errBuf )
244+
245+ testErr := mssql.Error {
246+ Number : 50000 ,
247+ Class : 16 ,
248+ State : 1 ,
249+ ServerName : "testserver" ,
250+ ProcName : "myStoredProc" ,
251+ LineNo : 10 ,
252+ Message : "Error raised from stored procedure." ,
253+ }
254+
255+ f .AddError (testErr )
256+ output := errBuf .String ()
257+ // Raw mode should NOT include the header
258+ assert .NotContains (t , output , "Msg 50000" )
259+ assert .NotContains (t , output , "Level 16" )
260+ assert .NotContains (t , output , "Procedure myStoredProc" )
261+ // But should still contain the actual error message
262+ assert .Contains (t , output , "Error raised from stored procedure." )
263+ }
0 commit comments