mirror of https://github.com/zulip/zulip.git
refactor: Change BugdownRenderingException to MarkdownRenderingException.
This commit is part of series of commits aimed at renaming bugdown to markdown.
This commit is contained in:
parent
3f5fc13491
commit
05cce86670
|
@ -86,9 +86,9 @@ from zerver.lib.email_validation import (
|
||||||
)
|
)
|
||||||
from zerver.lib.emoji import emoji_name_to_emoji_code, get_emoji_file_name
|
from zerver.lib.emoji import emoji_name_to_emoji_code, get_emoji_file_name
|
||||||
from zerver.lib.exceptions import (
|
from zerver.lib.exceptions import (
|
||||||
BugdownRenderingException,
|
|
||||||
ErrorCode,
|
ErrorCode,
|
||||||
JsonableError,
|
JsonableError,
|
||||||
|
MarkdownRenderingException,
|
||||||
StreamDoesNotExistError,
|
StreamDoesNotExistError,
|
||||||
StreamWithIDDoesNotExistError,
|
StreamWithIDDoesNotExistError,
|
||||||
)
|
)
|
||||||
|
@ -1055,7 +1055,7 @@ def render_incoming_message(message: Message,
|
||||||
mention_data=mention_data,
|
mention_data=mention_data,
|
||||||
email_gateway=email_gateway,
|
email_gateway=email_gateway,
|
||||||
)
|
)
|
||||||
except BugdownRenderingException:
|
except MarkdownRenderingException:
|
||||||
raise JsonableError(_('Unable to render message'))
|
raise JsonableError(_('Unable to render message'))
|
||||||
return rendered_content
|
return rendered_content
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ class OrganizationOwnerRequired(JsonableError):
|
||||||
def msg_format() -> str:
|
def msg_format() -> str:
|
||||||
return OrganizationOwnerRequired.OWNER_REQUIRED_MESSAGE
|
return OrganizationOwnerRequired.OWNER_REQUIRED_MESSAGE
|
||||||
|
|
||||||
class BugdownRenderingException(Exception):
|
class MarkdownRenderingException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class InvalidAPIKeyError(JsonableError):
|
class InvalidAPIKeyError(JsonableError):
|
||||||
|
|
|
@ -49,7 +49,7 @@ from zerver.lib.emoji import (
|
||||||
name_to_codepoint,
|
name_to_codepoint,
|
||||||
translate_emoticons,
|
translate_emoticons,
|
||||||
)
|
)
|
||||||
from zerver.lib.exceptions import BugdownRenderingException
|
from zerver.lib.exceptions import MarkdownRenderingException
|
||||||
from zerver.lib.markdown import fenced_code
|
from zerver.lib.markdown import fenced_code
|
||||||
from zerver.lib.markdown.fenced_code import FENCE_RE
|
from zerver.lib.markdown.fenced_code import FENCE_RE
|
||||||
from zerver.lib.mention import extract_user_group, possible_mentions, possible_user_group_mentions
|
from zerver.lib.mention import extract_user_group, possible_mentions, possible_user_group_mentions
|
||||||
|
@ -2362,7 +2362,7 @@ def do_convert(content: str,
|
||||||
# rest of the codebase from any bugs where we end up rendering
|
# rest of the codebase from any bugs where we end up rendering
|
||||||
# something huge.
|
# something huge.
|
||||||
if len(rendered_content) > MAX_MESSAGE_LENGTH * 10:
|
if len(rendered_content) > MAX_MESSAGE_LENGTH * 10:
|
||||||
raise BugdownRenderingException(
|
raise MarkdownRenderingException(
|
||||||
f'Rendered content exceeds {MAX_MESSAGE_LENGTH * 10} characters (message {logging_message_id})'
|
f'Rendered content exceeds {MAX_MESSAGE_LENGTH * 10} characters (message {logging_message_id})'
|
||||||
)
|
)
|
||||||
return rendered_content
|
return rendered_content
|
||||||
|
@ -2377,7 +2377,7 @@ def do_convert(content: str,
|
||||||
logging_message_id,
|
logging_message_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
raise BugdownRenderingException()
|
raise MarkdownRenderingException()
|
||||||
finally:
|
finally:
|
||||||
# These next three lines are slightly paranoid, since
|
# These next three lines are slightly paranoid, since
|
||||||
# we always set these right before actually using the
|
# we always set these right before actually using the
|
||||||
|
|
|
@ -82,7 +82,7 @@ import markdown
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
from markdown.extensions.codehilite import CodeHilite, CodeHiliteExtension
|
from markdown.extensions.codehilite import CodeHilite, CodeHiliteExtension
|
||||||
|
|
||||||
from zerver.lib.exceptions import BugdownRenderingException
|
from zerver.lib.exceptions import MarkdownRenderingException
|
||||||
from zerver.lib.tex import render_tex
|
from zerver.lib.tex import render_tex
|
||||||
|
|
||||||
# Global vars
|
# Global vars
|
||||||
|
@ -127,7 +127,7 @@ Missing required -X argument in curl command:
|
||||||
regex = r'curl [-](sS)?X "?(GET|DELETE|PATCH|POST)"?'
|
regex = r'curl [-](sS)?X "?(GET|DELETE|PATCH|POST)"?'
|
||||||
if line.startswith('curl'):
|
if line.startswith('curl'):
|
||||||
if re.search(regex, line) is None:
|
if re.search(regex, line) is None:
|
||||||
raise BugdownRenderingException(error_msg.format(command=line.strip()))
|
raise MarkdownRenderingException(error_msg.format(command=line.strip()))
|
||||||
|
|
||||||
|
|
||||||
CODE_VALIDATORS = {
|
CODE_VALIDATORS = {
|
||||||
|
|
|
@ -20,7 +20,7 @@ from zerver.lib.actions import (
|
||||||
from zerver.lib.alert_words import get_alert_word_automaton
|
from zerver.lib.alert_words import get_alert_word_automaton
|
||||||
from zerver.lib.create_user import create_user
|
from zerver.lib.create_user import create_user
|
||||||
from zerver.lib.emoji import get_emoji_url
|
from zerver.lib.emoji import get_emoji_url
|
||||||
from zerver.lib.exceptions import BugdownRenderingException
|
from zerver.lib.exceptions import MarkdownRenderingException
|
||||||
from zerver.lib.mention import possible_mentions, possible_user_group_mentions
|
from zerver.lib.mention import possible_mentions, possible_user_group_mentions
|
||||||
from zerver.lib.message import render_markdown
|
from zerver.lib.message import render_markdown
|
||||||
from zerver.lib.request import JsonableError
|
from zerver.lib.request import JsonableError
|
||||||
|
@ -2090,7 +2090,7 @@ class BugdownApiTests(ZulipTestCase):
|
||||||
class BugdownErrorTests(ZulipTestCase):
|
class BugdownErrorTests(ZulipTestCase):
|
||||||
def test_bugdown_error_handling(self) -> None:
|
def test_bugdown_error_handling(self) -> None:
|
||||||
with self.simulated_markdown_failure():
|
with self.simulated_markdown_failure():
|
||||||
with self.assertRaises(BugdownRenderingException):
|
with self.assertRaises(MarkdownRenderingException):
|
||||||
bugdown_convert('')
|
bugdown_convert('')
|
||||||
|
|
||||||
def test_send_message_errors(self) -> None:
|
def test_send_message_errors(self) -> None:
|
||||||
|
@ -2109,7 +2109,7 @@ class BugdownErrorTests(ZulipTestCase):
|
||||||
|
|
||||||
with mock.patch('zerver.lib.markdown.timeout', return_value=msg), \
|
with mock.patch('zerver.lib.markdown.timeout', return_value=msg), \
|
||||||
mock.patch('zerver.lib.markdown.bugdown_logger'):
|
mock.patch('zerver.lib.markdown.bugdown_logger'):
|
||||||
with self.assertRaises(BugdownRenderingException):
|
with self.assertRaises(MarkdownRenderingException):
|
||||||
bugdown_convert(msg)
|
bugdown_convert(msg)
|
||||||
|
|
||||||
def test_curl_code_block_validation(self) -> None:
|
def test_curl_code_block_validation(self) -> None:
|
||||||
|
@ -2128,7 +2128,7 @@ class BugdownErrorTests(ZulipTestCase):
|
||||||
'```',
|
'```',
|
||||||
]
|
]
|
||||||
|
|
||||||
with self.assertRaises(BugdownRenderingException):
|
with self.assertRaises(MarkdownRenderingException):
|
||||||
processor.run(markdown)
|
processor.run(markdown)
|
||||||
|
|
||||||
def test_curl_code_block_without_validation(self) -> None:
|
def test_curl_code_block_without_validation(self) -> None:
|
||||||
|
|
Loading…
Reference in New Issue