Fixed a bug in error callbacks