Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Latest commit

 

History

History
38 lines (30 loc) · 785 Bytes

error_snippet.md

File metadata and controls

38 lines (30 loc) · 785 Bytes

utils.error_snippet

Procedure to get snippet of procedure / function where error was encountered.

Usage

You can use the utils.error_snippet procedure as follows:

BEGIN TRY
  -- Execute procedure with any possible error.
  EXEC proc_name 'arg1', 'arg2';
END TRY
BEGIN CATCH
  -- This procedure prints the errored snippet from given procedure.
  EXEC utils.error_snippet 'proc_name', @adjacent_line_count = 10;

  THROW;
END CATCH

Output

Error snippet with the error line highlighted:

12
13      UPDATE [qa].[qa_result_fact_timesheet]
14      SET is_active=0
15      WHERE is_active=1;
16
17 -->  INSERT INTO [qa].[qa_result_fact_timesheet]
18      (
19        qa_datetime,
20        last_timesheet_file,
21        test_case,
22        qa_result,