trap an exception ......

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    trap an exception ......

    heloo friends .... i want to solve a magic .......

    see my code carefully .....

    try
    {
    //My Code......
    ---------------
    ----------------
    }catch(Eexcepti on e)
    {
    //I want to add code where the exception occures and why .......so that my eyes automatically go there and remove the exception cause
    }

    is it possible .......
  • DeMan
    Top Contributor
    • Nov 2006
    • 1799

    #2
    I believe you can (inside the catch) do an e.stackTrace() or e.printStackTra ce (or something like that, consult the API )
    Or if you want less information you can print e.toString()

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      What do you mean by
      so that my eyes automatically go there and remove the exception cause

      Comment

      • DeMan
        Top Contributor
        • Nov 2006
        • 1799

        #4
        public class exception(Strin g s) extends EyeControl {}

        Comment

        • dmjpro
          Top Contributor
          • Jan 2007
          • 2476

          #5
          sorry friends ... probably u misunderstood me ......

          i meant to say is there any way to trap the line number ....... or can easily get the exception cause .....

          plzzzzzzzzzzzz help me out .....

          Comment

          • DeMan
            Top Contributor
            • Nov 2006
            • 1799

            #6
            I'm pretty sure the stack trace will print the line number

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              Originally posted by dmjpro
              sorry friends ... probably u misunderstood me ......

              i meant to say is there any way to trap the line number ....... or can easily get the exception cause .....

              plzzzzzzzzzzzz help me out .....
              The trace will include the line number. Make it a point however to catch more specific exceptions. You should know all the possible exceptions that can be threown in your code

              Comment

              Working...