add function handleError by controller