Adding callbacks for errors, bug 1707.

Change-Id: Ia7078faef392517f6028a9ddd3c1aea5d4e0a799
Signed-off-by: Alex Fan <railor33@gmail.com>