NilObjectException, but where?

Hello

I’m running into a NilObjectException on the HandleSpecialURL in a webapp. Which is weird because the same code on a button works just fine.
This is the code:

pageMain.HTMLMain.LoadZone(App.CurrentProject.GetZone("defaultZone"))

The debugger shows this line, but how can I see what actually is Nil? Is it pageMain? HTMLMain? LoadZone? CurrentProject? GetZone?
Can’t seem to figure it out with the debugger.
Thanks!

You will have to test this like

if App.CurrentProject = nil then break
if App.CurrentProject.GetZone(“defaultZone”) then break

and so on. You should do that anyway.

a button on a layout has a session associated with it

HandleSpecialUrl doesn’t

so if that code depends on a session some where thats likely where the nil object comes from

Thanks Norman, that would be it indeed.

Soo, quick thinking: I should get the Session ID, let the page that calls the /special/ link add that session ID as a parameter, then in HandeSpecialURL try to get the webpage of the given Session ID.

So using WebApplication.SessionWithIdentifier and then WebSession.PageWithName?

Thanks

[quote=341103:@Beatrix Willius]You will have to test this like

if App.CurrentProject = nil then break
if App.CurrentProject.GetZone(“defaultZone”) then break

and so on. You should do that anyway.[/quote]

Thanks for the tip Beatrix, that is in theory true, and it should certainly be done with userinput e.d. But here I’m handling instances that are hardcoded, they NEVER can be nil, or Xojo must fail at some point, but then a NilObjectException would be the least of my concern.
Handling every possible error ever would probably quadruple my code, making it harder to read while having no real benefit.