Handle errors properly in TRUNC function