add error handler before onSecure