error handling

Refs https://github.com/cakephp/cakephp/pull/2594