2

I've been using Haxe for a while and I'm debuging with the Windows target (OpenFL).

When I put a try/catch somewhere it just says for example "Null object reference" - it doesn't say the line number and the class, so I have to keep putting traces to find in which line it has thrown the error.

Can someone help me?

Gama11
  • 31,714
  • 9
  • 78
  • 100
Thiago Sabin
  • 137
  • 1
  • 12

1 Answers1

2

You might need to enable stack traces by adding the following define to your project.xml file if you're compiling in release mode:

<haxedef name="HXCPP_STACK_LINE" />

Also, you won't be able to catch null reference exceptions or get stack traces for them unless the following is defined (for performance reasons):

<haxedef name="HXCPP_CHECK_POINTER" />

With these two, you should see a stack trace in FlashDevelop's Output panel.

You can find some good info on these flags and hxcpp debugging in general here. You might also want to check out the crashdumper library.

Gama11
  • 31,714
  • 9
  • 78
  • 100
  • i'm using catch (e:Dynamic){ trace(e); } and still i only get "MainDomain.hx:218: Null Object Reference" being mainDomain.hx:218 the line of the catch... am i doing something wrong? – Thiago Sabin Feb 16 '17 at 13:22
  • 1
    You can just leave the exception uncaught if you want to see the stack trace. Alternatively, you can use `haxe.CallStack` to get at the stack trace: https://gist.github.com/Gama11/adcc268fb00d3f442c969e54940db831 – Gama11 Feb 16 '17 at 13:39