Update REST error handling to allow typed errors