Sun Studio 12 Update 1: Debugging a Program With dbx

intercept [-all] [-x] [-set] [typename] Command

You can intercept, or catch, exceptions of a specific type before the stack has been unwound. Use the intercept command with no arguments to list the types that are being intercepted. Use -all to intercept all exceptions. Use typename to add a type to the intercept list. Use -x to exclude a particular type to the excluded list to keep it from being intercepted. Use -set to clear both the intercept list and the excluded list, and set the lists to intercept or exclude only throws of the specified types

For example, to intercept all types except int, you could type:


(dbx) intercept -all -x int

To intercept exceptions of type Error, you would type:


(dbx) intercept Error

After intercepting too many CommonError exceptions, you could exclude these exceptions by typing:


(dbx) intercept -x CommonError

Typing the intercept command with no arguments would then show that the intercept list includes unhandled exceptions and unexpected exceptions, which are intercepted by default, plus exceptions of class Error except for those of class CommonError.


(dbx) intercept
-unhandled   -unexpected   class Error -x class CommonError

If you then realize that Error is not the class of exceptions that interests you, but you do not know the name of the exception class you are looking for, you could try intercepting all exceptions except those of class Error by typing


(dbx) intercept -all -x Error

For more information, see intercept Command.