If the code you are calling the function from is inside a try catch block then you can catch the error if the function is in another unit. Its all about scope. Where are you calling your function from?
See the example below. The test script is in a try catch block. It is calling a function in another unit in my project called 'library'. A javascript error is thrown during execution of the AddText function and is logged in the test log.
//USEUNIT library
function testScript(){
//calls a function from library unit that is intentionally broken
try{
AddText("TextBox","123");
}
catch
(e){
Log.Message(e.message);
}
}