Implement a general JsonController which can render errors in json form and send the proper headers.