bugdown: Move BugdownRenderingException to exceptions.py.

This commit is contained in:
Shubham Dhama 2018-06-21 18:39:14 +05:30 committed by Tim Abbott
parent 89fefcd1a2
commit b9a8c4df8c
4 changed files with 8 additions and 7 deletions

View File

@ -16,7 +16,6 @@ from analytics.lib.counts import COUNT_STATS, do_increment_logging_stat, \
RealmCount
from zerver.lib.bugdown import (
BugdownRenderingException,
version as bugdown_version,
url_embed_preview_enabled_for_realm
)
@ -120,7 +119,7 @@ from zerver.lib.alert_words import user_alert_words, add_user_alert_words, \
from zerver.lib.notifications import clear_scheduled_emails, \
clear_scheduled_invitation_emails, enqueue_welcome_emails
from zerver.lib.narrow import check_supported_events_narrow_filter
from zerver.lib.exceptions import JsonableError, ErrorCode
from zerver.lib.exceptions import JsonableError, ErrorCode, BugdownRenderingException
from zerver.lib.sessions import delete_user_sessions
from zerver.lib.upload import attachment_url_re, attachment_url_to_path_id, \
claim_attachment, delete_message_image, upload_emoji_image

View File

@ -53,6 +53,7 @@ from zerver.models import (
)
import zerver.lib.mention as mention
from zerver.lib.tex import render_tex
from zerver.lib.exceptions import BugdownRenderingException
FullNameInfo = TypedDict('FullNameInfo', {
'id': int,
@ -78,9 +79,6 @@ STREAM_LINK_REGEX = r"""
\*\* # ends by double asterisks
"""
class BugdownRenderingException(Exception):
pass
def rewrite_local_links_to_relative(link: str) -> str:
""" If the link points to a local destination we can just switch to that
instead of opening a new tab. """

View File

@ -153,3 +153,6 @@ class StreamDoesNotExistError(JsonableError):
class RateLimited(PermissionDenied):
def __init__(self, msg: str="") -> None:
super().__init__(msg)
class BugdownRenderingException(Exception):
pass

View File

@ -13,6 +13,7 @@ from zerver.lib.alert_words import alert_words_in_realm
from zerver.lib.camo import get_camo_url
from zerver.lib.create_user import create_user
from zerver.lib.emoji import get_emoji_url
from zerver.lib.exceptions import BugdownRenderingException
from zerver.lib.mention import possible_mentions, possible_user_group_mentions
from zerver.lib.message import render_markdown
from zerver.lib.request import (
@ -1247,7 +1248,7 @@ class BugdownApiTests(ZulipTestCase):
class BugdownErrorTests(ZulipTestCase):
def test_bugdown_error_handling(self) -> None:
with self.simulated_markdown_failure():
with self.assertRaises(bugdown.BugdownRenderingException):
with self.assertRaises(BugdownRenderingException):
bugdown_convert('')
def test_send_message_errors(self) -> None:
@ -1264,7 +1265,7 @@ class BugdownErrorTests(ZulipTestCase):
msg = u'* a\n' * MAX_MESSAGE_LENGTH # Rendering is >100K characters
with self.simulated_markdown_failure():
with self.assertRaises(bugdown.BugdownRenderingException):
with self.assertRaises(BugdownRenderingException):
bugdown_convert(msg)