Restructure error reporting