XF 2.1 Graceful error handling + options validation

Sysnative

Well-known member
Are there any tutorials or guidance on handling errors and how to display a message to the user?

At the moment I have a function that extends the user class to allow {$user.getApiResults} to return an array and make it available to the template. At the moment if an admin has not entered the API key into the options the function crashes and makes the page unavailable.

How can I pass back a meaningful error to the user, and also avoid the page crashing if the API key is missing?

Second question is around option validation - I'd like to make sure that the user only ever inputs an alphanumeric API key into the options, and only run the function if that's correct.

What's the best way of doing this?
 
Top Bottom