Results 1 to 2 of 2
  1. #1
    victoryo is offline Member
    Join Date
    Dec 2011
    Posts
    16
    Rep Power
    0

    Default Java return line of the error

    Hi all,

    Iam trieing to print an error with a linenumber where the error is at.

    Here is a part of my code.

    Java Code:
             if (turns.isEmpty()) 
                      {
                            throw new FileException("\r\nTurn <" + turns + "> contains zero darts" , i , file, turns);
                      }
    What i would like to show at i is the linenumber where the error is.
    turns is filled by inserting a file
    Java Code:
    while((turns = reader.readLine()) != null)

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Java return line of the error

    I think there is a way to get the contents of the stack trace into a variable.
    Then you would have to scan the contents of that variable to find the line number you are interested in.

Similar Threads

  1. Return a value from Method - error
    By rgeurts in forum New To Java
    Replies: 5
    Last Post: 03-28-2011, 10:04 PM
  2. Return statement error
    By Exothesis in forum New To Java
    Replies: 2
    Last Post: 10-13-2010, 02:56 AM
  3. Replies: 1
    Last Post: 03-10-2010, 02:53 PM
  4. How to return to next line of code after calling a public class?
    By devdevi@comcast.net in forum New To Java
    Replies: 1
    Last Post: 02-02-2009, 07:46 PM
  5. New line or Carriage Return through FileWriter
    By johnt in forum New To Java
    Replies: 2
    Last Post: 05-20-2007, 10:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •