Are there any Netbeans "tags" (ala @...) that will (upon compiling) insert the line number that the tag is on? So, if the tag is on line 50, Netbeans will replace the tag with "50"?
I thought when throwing an exception, it might be a good idea to reference the line number in the .java file?
I don't think there's a way to do this as you are describing.
If you have an exception you can generally get the line number it was constructed on programmatically:
e.getStackTrace()[0].getLineNumber()
If you really want to get the line number of the current source line (and it doesn't sound like you do), I suppose you could do it like this:
new Throwable().getStackTrace()[0].getLineNumber()
If you just want to print the stack trace, there's a method for that:
e.printStackTrace();
By default it will print the stack trace to System.err. There are overrides to print to other places. If you want to customize the output format you will have to call getStackTrace()
and print it yourself.