PosException.hx 717 B

123456789101112131415161718192021222324252627
  1. package haxe.exceptions;
  2. /**
  3. An exception that carry position information of a place where it was created.
  4. **/
  5. class PosException extends Exception {
  6. /**
  7. Position where this exception was created.
  8. **/
  9. public final posInfos:PosInfos;
  10. public function new(message:String, ?previous:Exception, ?pos:PosInfos):Void {
  11. super(message, previous);
  12. if (pos == null) {
  13. posInfos = { fileName:'(unknown)', lineNumber:0, className:'(unknown)', methodName:'(unknown)' }
  14. } else {
  15. posInfos = pos;
  16. }
  17. }
  18. /**
  19. Returns exception message.
  20. **/
  21. override function toString():String {
  22. return '${super.toString()} in ${posInfos.className}.${posInfos.methodName} at ${posInfos.fileName}:${posInfos.lineNumber}';
  23. }
  24. }