Try this:
if(orderLinesTable){
alert ("before");
linksInOrderLinesTable = orderLinesTable.getElementsByTagName("a");
alert ("after");
if the orderLinesTable.getElementsByTagName causes the error, the second alert will not be executed.
Try this:
if(orderLinesTable){
alert ("before");
linksInOrderLinesTable = orderLinesTable.getElementsByTagName("a");
alert ("after");
if the orderLinesTable.getElementsByTagName causes the error, the second alert will not be executed.