The Java method that you write to implement an external routine (UDF or external stored procedure) can use the SQLException class to throw an exception. The method may also need to handle exceptions that are thrown when the method uses a Teradata application class and an error occurs.