Error handler to auto-define variables