This function may be called anywhere within the scope of a CATCH block.
ERROR_LINE returns the line number at which the error occurred regardless of the number of times it is called or where it is called within the scope of the CATCH block. This contrasts with functions, such as @@ERROR, which return an error number in the statement immediately following the one that causes an error or in the first statement of a CATCH block.
In nested CATCH blocks, ERROR_LINE returns the error line number specific to the scope of the CATCH block in which it is referenced. For example, the CATCH block of a TRY…CATCH construct could contain a nested TRY…CATCH construct. Within the nested CATCH block, ERROR_LINE returns the line number for the error that invoked the nested CATCH block. If ERROR_LINE is run in the outer CATCH block, it returns the line number for the error that invoked that CATCH block.