From 59d22e7cb87ce42402f49be33ff41eea4a6a20ce Mon Sep 17 00:00:00 2001 From: Harshit Bansal Date: Tue, 31 Jan 2017 02:10:35 +0530 Subject: [PATCH] realm_emoji: Cleanup an unreachable try/except block. Fixes: #3515. --- tools/lint-all | 1 - zerver/views/realm_emoji.py | 8 ++------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/tools/lint-all b/tools/lint-all index 0223f4c58b..36a84837ec 100755 --- a/tools/lint-all +++ b/tools/lint-all @@ -373,7 +373,6 @@ def build_custom_checkers(by_lang): ('zerver/views/streams.py', 'return json_error(property_conversion)'), ('zerver/views/streams.py', 'return json_error(e.error, data=result, status=404)'), # We can't do anything about this. - ('zerver/views/realm_emoji.py', 'return json_error(e.messages[0])'), ('zerver/views/realm_filters.py', 'return json_error(e.messages[0], data={"errors": dict(e)})'), ]), 'description': 'Argument to json_error should a literal string enclosed by _()'}, diff --git a/zerver/views/realm_emoji.py b/zerver/views/realm_emoji.py index ee8ed201f5..2c12ca0875 100644 --- a/zerver/views/realm_emoji.py +++ b/zerver/views/realm_emoji.py @@ -1,14 +1,13 @@ from __future__ import absolute_import from django.http import HttpRequest, HttpResponse -from django.core.exceptions import ValidationError from django.utils.translation import ugettext as _ from typing import Text from zerver.models import UserProfile from zerver.lib.emoji import check_emoji_admin, check_valid_emoji_name, check_valid_emoji from zerver.lib.request import JsonableError, REQ, has_request_variables -from zerver.lib.response import json_success, json_error +from zerver.lib.response import json_success from zerver.lib.actions import check_add_realm_emoji, do_remove_realm_emoji def list_emoji(request, user_profile): @@ -23,10 +22,7 @@ def upload_emoji(request, user_profile, emoji_name=None, url=REQ()): # type: (HttpRequest, UserProfile, Text, Text) -> HttpResponse check_valid_emoji_name(emoji_name) check_emoji_admin(user_profile) - try: - check_add_realm_emoji(user_profile.realm, emoji_name, url, author=user_profile) - except ValidationError as e: - return json_error(e.messages[0]) + check_add_realm_emoji(user_profile.realm, emoji_name, url, author=user_profile) return json_success() def delete_emoji(request, user_profile, emoji_name):