Strengthen error handling in templates panel.

Fix #292.