It's unclear what you're asking, please show some code.
getLineNumber()
and getStackTraceString()
should include the line number (among others). Check https://developer.salesforce.com/forums?id=906F00000008xc4IAA for sample message.
As for "how to print" - there's a try-catch example. Either simply push it at System.debug()
or (if it's visualforce context) you can add a pagemessage.
You can also go to setup -> debug log, attach the tracking to your user and retry the action? You'll see the stacktrace and other goodies, line numbers next to the names of called methods...