optional encoding on errors

Optional encoding for validation errors