How to debug preferences page of app?

I have a bug somewhere from code in the preferences section of an app. The bug causes this to appear when trying to load the app:

Unexpected Error

An unexpected error has occurred trying to load the app. Check [Logs] for more information.

Of course, the logs don't have any information at all. So, are my log settings deficient? If not, how does one debug these sorts of errors? Painstakingly double-check every line of code? That hasn't worked so far....

start with log.debug at the beginning and end of every method
Log.debg "medtod a start"
...
...
Log.debug "method a end"

Well, I'm stumped. Here's my test code.

preferences
{
    page name: "mainPage", title: "", install: true, uninstall: true
}

def mainPage() {
    dynamicPage(name: "mainPage") {
        input name: "Test", type: "text", title: "Test", required: true  
    }
}

It actually gives more info in this stub:

Unexpected Error

An unexpected error has occurred trying to load the app. Check [Logs] for more information.

Error: Cannot get property 'input' on null object

It must be something with this page structure, but I see a lot of apps use it. What am I missing here?

That input must be inside a section.

def mainPage() {
    dynamicPage(name: "mainPage") {
       section {
            input name: "Test", type: "text", title: "Test", required: true  
       }
    }
}
1 Like

Thanks Bruce! Seems like that would, could, or should have thrown a "compile" error on me of some sort. But perhaps that's not the way it works, or it's not worth doing. I'm only on my 3rd app/driver here, so still learning...

It's not a compile time error. Just know that anything that renders to the UI must be inside a section. That would be input, paragraph, and href.

Suppose you have a method:

def getDevice(which, capab) {
    input which, capab, title: "Select Device"
}

If you call that method from inside a section it works as expected. If you call it from outside a section it throws the error you saw. That sort of thing can't really be found at compile time.