Pyprohly: I don’t recommend trying to shoehorn every API exception you find into the `RedditAPIException` class. This class is a concrete class that should only be used for the API errors that look like “`{'json': {'errors': [['NO_TEXT', 'we need something here', 'title’]]}}`”. Anything that deviates from this format even slightly deserves its own class.

Even if there were a `BaseAPIException` I wouldn’t make `MediaPostFailed` a subclass of it since it’s not a part of the regular REST API and uses a different protocol.

bboe: > Even if there were a BaseAPIException I wouldn’t make MediaPostFailed a subclass of it since it’s not a part of the regular REST API and uses a different protocol.

That's an interesting point. All such exceptions should be under the umbrella of a PRAW API type exception. Users of the library shouldn't care which API PRAW is talking to in order to distinguish between what exceptions might be thrown. But under that, we could distinguish between classes of exceptions.
PythonCoderAS: > I don’t recommend trying to shoehorn every API exception you find into the `RedditAPIException` class. This class is a concrete class that should only be used for the API errors that look like “`{'json': {'errors': [['NO_TEXT', 'we need something here', 'title’]]}}`”. Anything that deviates from this format even slightly deserves its own class.
> 
> Even if there were a `BaseAPIException` I wouldn’t make `MediaPostFailed` a subclass of it since it’s not a part of the regular REST API and uses a different protocol.

Do you think it would be better to subclass this from `WebsocketException`, but then we would need to rework that as well. We could split `WebsocketException` into `WebsocketException` and `WebsocketConnectionException`, maybe. 
Pyprohly: Ah yes, there’s a `WebSocketException` exception. I do think it’s better have `MediaPostFailed` inherit from that instead.

Why would `WebSocketException` need reworking though?
PythonCoderAS: > Ah yes, there’s a `WebSocketException` exception. I do think it’s better have `MediaPostFailed` inherit from that instead.
> 
> Why would `WebSocketException` need reworking though?

The main reason is that `WebSocketException` currently has it's own set message and basically wraps an existing exception with a custom message.
Pyprohly: Yea, right. That `.original_exception` attribute shouldn’t be there.

Never wrap exceptions, it’s better to chain them: `raise MyException from exc`. Fix it.

PythonCoderAS: > Yea, right. That `.original_exception` attribute shouldn’t be there.
> 
> Never wrap exceptions, it’s better to chain them: `raise MyException from exc`. Fix it.

We can't do that now, it's been part of PRAW 7. It needs to be deprecated. 
diff --git a/CHANGES.rst b/CHANGES.rst
index 1aa4382c..bc9621d4 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -25,6 +25,10 @@ Unreleased
 * :meth:`.SubredditRemovalReasons.__getitem__` now takes integers and slices to
   get removal reasons from the list of reasons as returned by Reddit.
 
+**Deprecated**
+
+* :attr:`.WebSocketException.original_exception` is deprecated and slated for removal in PRAW 8.0.
+
 **Fixed**
 
 * An issue where certain subreddit settings could not be set through
@@ -34,6 +38,9 @@ Unreleased
   update request.
 * Instances of ``BadRequest``\ s captured by PRAW that do not contain any
   detailed JSON data are re-raised as the original ``BadRequest``.
+* :meth:`.submit_image` and :meth:`.submit_video` will throw
+  :class:`.MediaPostFailed` when Reddit fails to post an image or video post.
+
 
 7.0.0 (2020/04/24)
 ------------------
diff --git a/praw/exceptions.py b/praw/exceptions.py
index 8791d0f2..3a05e0e3 100644
--- a/praw/exceptions.py
+++ b/praw/exceptions.py
@@ -244,11 +244,47 @@ class TooLargeMediaException(ClientException):
 class WebSocketException(ClientException):
     """Indicate exceptions caused by use of WebSockets."""
 
-    def __init__(self, message: str, exception: Exception):
+    @property
+    def original_exception(self) -> Exception:
+        """Access the original_exception attribute (now deprecated)."""
+        warn(
+            "Accessing the attribute original_exception is deprecated. Please"
+            " rewrite your code in such a way that this attribute does not"
+            " need to be used. It will be removed in PRAW 8.0.",
+            category=DeprecationWarning,
+            stacklevel=2,
+        )
+        return self._original_exception
+
+    @original_exception.setter
+    def original_exception(self, value: Exception):
+        self._original_exception = value
+
+    @original_exception.deleter
+    def original_exception(self):
+        del self._original_exception
+
+    def __init__(self, message: str, exception: Optional[Exception]):
         """Initialize a WebSocketException.
 
         :param message: The exception message.
         :param exception: The exception thrown by the websocket library.
+
+            .. note:: This parameter is deprecated. It will be removed in PRAW
+                8.0.
         """
         super().__init__(message)
-        self.original_exception = exception
+        self._original_exception = exception
+
+
+class MediaPostFailed(WebSocketException):
+    """Indicate exceptions where media uploads failed.."""
+
+    def __init__(self):
+        """Instantiate MediaPostFailed."""
+        super().__init__(
+            "The attempted media upload action has failed. Possible causes"
+            " include the corruption of media files. Check that the media "
+            "file can be opened on your local machine.",
+            None,
+        )
diff --git a/praw/models/reddit/subreddit.py b/praw/models/reddit/subreddit.py
index 52e0beba..6fdce155 100644
--- a/praw/models/reddit/subreddit.py
+++ b/praw/models/reddit/subreddit.py
@@ -18,6 +18,7 @@ from ...const import API_PATH, JPEG_HEADER
 from ...exceptions import (
     ClientException,
     InvalidFlairTemplateID,
+    MediaPostFailed,
     RedditAPIException,
     TooLargeMediaException,
     WebSocketException,
@@ -612,6 +613,8 @@ class Subreddit(
                 "the original exception.",
                 ws_exception,
             )
+        if ws_update.get("type") == "failed":
+            raise MediaPostFailed
         url = ws_update["payload"]["redirect"]
         return self._reddit.submission(url=url)
 

KeyError from corrupted image uploads
On behalf of u/Smoking-Snake (https://www.reddit.com/r/redditdev/comments/g7s1yx/praw_keyerror_redirect_when_trying_to_upload/)

**Describe the bug**
<!-- A clear and concise description of what the bug is. -->Invalid media uploads return an empty payload but a type of failed. PRAW expects a payload with a redirect, and since there is no payload, a KeyError is thrown.

**Expected behavior**
<!-- A clear and concise description of what you expected to happen. -->
An exception that the media is valid should be raised.

**Code/Logs**
<!-- include your code, without the Reddit() initialization, so as to not leak private credentials. -->

**System Info**
 - OS: ?
 - Python: ?
 - PRAW Version: 7.0.0

diff --git a/tests/unit/models/reddit/test_subreddit.py b/tests/unit/models/reddit/test_subreddit.py
index b51d8055..28b4e7a2 100644
--- a/tests/unit/models/reddit/test_subreddit.py
+++ b/tests/unit/models/reddit/test_subreddit.py
@@ -1,7 +1,9 @@
+import json
 import pickle
-
 import pytest
+from unittest import mock
 
+from praw.exceptions import MediaPostFailed
 from praw.models import Subreddit, WikiPage
 from praw.models.reddit.subreddit import SubredditFlairTemplates
 
@@ -61,6 +63,21 @@ class TestSubreddit(UnitTest):
         assert hash(subreddit2) != hash(subreddit3)
         assert hash(subreddit1) != hash(subreddit3)
 
+    @mock.patch(
+        "praw.Reddit.post",
+        return_value={"json": {"data": {"websocket_url": ""}}},
+    )
+    @mock.patch("praw.models.Subreddit._upload_media", return_value="")
+    @mock.patch("websocket.create_connection")
+    def test_invalid_media(
+        self, connection_mock, _mock_upload_media, _mock_post
+    ):
+        connection_mock().recv.return_value = json.dumps(
+            {"payload": {}, "type": "failed"}
+        )
+        with pytest.raises(MediaPostFailed):
+            self.reddit.subreddit("test").submit_image("Test", "dummy path")
+
     def test_pickle(self):
         subreddit = Subreddit(
             self.reddit, _data={"display_name": "name", "id": "dummy"}
diff --git a/tests/unit/test_deprecations.py b/tests/unit/test_deprecations.py
index 49b9e654..57d3f7da 100644
--- a/tests/unit/test_deprecations.py
+++ b/tests/unit/test_deprecations.py
@@ -2,7 +2,7 @@
 
 import pytest
 
-from praw.exceptions import APIException
+from praw.exceptions import APIException, WebSocketException
 
 from . import UnitTest
 
@@ -39,3 +39,14 @@ class TestDeprecation(UnitTest):
             "/other/subredditrules.html#praw.models.reddit.rules."
             "SubredditRules.__call__)."
         )
+
+    def test_web_socket_exception_attribute(self):
+        exc = WebSocketException("Test", Exception("Test"))
+        with pytest.raises(DeprecationWarning) as excinfo:
+            _ = exc.original_exception
+        assert (
+            excinfo.value.args[0]
+            == "Accessing the attribute original_exception is deprecated."
+            " Please rewrite your code in such a way that this attribute does "
+            "not need to be used. It will be removed in PRAW 8.0."
+        )
diff --git a/tests/unit/test_exceptions.py b/tests/unit/test_exceptions.py
index c6a422fa..0822945f 100644
--- a/tests/unit/test_exceptions.py
+++ b/tests/unit/test_exceptions.py
@@ -8,6 +8,7 @@ from praw.exceptions import (
     InvalidFlairTemplateID,
     InvalidImplicitAuth,
     InvalidURL,
+    MediaPostFailed,
     MissingRequiredAttributeException,
     PRAWException,
     RedditAPIException,
@@ -178,10 +179,29 @@ class TestWebSocketException:
             str(WebSocketException("error message", None)) == "error message"
         )
 
+    @pytest.mark.filterwarnings("ignore", category=DeprecationWarning)
     def test_exception_attr(self):
-        assert WebSocketException(None, None).original_exception is None
+        exc = WebSocketException(None, None)
+        assert exc.original_exception is None
         assert isinstance(WebSocketException(None, Exception()), Exception)
         assert (
             str(WebSocketException(None, Exception("test")).original_exception)
             == "test"
         )
+        exc.original_exception = Exception()
+        assert isinstance(exc.original_exception, Exception)
+        del exc.original_exception
+        assert "_original_exception" not in vars(exc)
+
+
+class TestMediaPostFailed:
+    def test_inheritance(self):
+        assert issubclass(MediaPostFailed, WebSocketException)
+
+    def test_message(self):
+        assert (
+            str(MediaPostFailed())
+            == "The attempted media upload action has failed. Possible causes"
+            " include the corruption of media files. Check that the media "
+            "file can be opened on your local machine."
+        )

pip install -e .[dev]
parse_log_pytest
pytest
pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
attrs @ file:///croot/attrs_1668696182826/work
Babel==2.14.0
betamax==0.8.1
betamax-matchers==0.4.0
black==23.3.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
cfgv==3.3.1
charset-normalizer==3.4.1
click==8.1.8
coverage==7.2.7
distlib==0.3.9
docutils==0.17.1
execnet==2.0.2
filelock==3.12.2
flake8==5.0.4
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
identify==2.5.24
idna==3.10
imagesize==1.4.1
importlib-metadata==4.2.0
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
Jinja2==3.1.6
MarkupSafe==2.1.5
mccabe==0.7.0
mypy-extensions==1.0.0
nodeenv==1.9.1
packaging @ file:///croot/packaging_1671697413597/work
pathspec==0.11.2
platformdirs==2.6.2
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
-e git+https://github.com/praw-dev/praw.git@8c5b7c93af2067c489c05970f8eaef8a0668aafa#egg=praw
prawcore==1.5.0
pre-commit==2.21.0
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pycodestyle==2.9.1
pydocstyle==6.3.0
pyflakes==2.5.0
Pygments==2.17.2
pytest==7.1.2
pytest-asyncio==0.21.2
pytest-cov==4.1.0
pytest-mock==3.11.1
pytest-xdist==3.5.0
pytz==2025.2
PyYAML==6.0.1
requests==2.31.0
requests-toolbelt==1.0.0
snowballstemmer==2.2.0
Sphinx==2.4.5
sphinx-rtd-theme==1.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
typed-ast==1.5.5
typing_extensions==4.7.1
update-checker==0.18.0
urllib3==2.0.7
virtualenv==20.16.2
websocket-client==1.6.1
zipp @ file:///croot/zipp_1672387121353/work

name: praw
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=22.1.0=py37h06a4308_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - flit-core=3.6.0=pyhd3eb1b0_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=22.0=py37h06a4308_0
  - pip=22.3.1=py37h06a4308_0
  - pluggy=1.0.0=py37h06a4308_1
  - py=1.11.0=pyhd3eb1b0_0
  - pytest=7.1.2=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py37h06a4308_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.11.0=py37h06a4308_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - babel==2.14.0
      - betamax==0.8.1
      - betamax-matchers==0.4.0
      - black==23.3.0
      - cfgv==3.3.1
      - charset-normalizer==3.4.1
      - click==8.1.8
      - coverage==7.2.7
      - distlib==0.3.9
      - docutils==0.17.1
      - execnet==2.0.2
      - filelock==3.12.2
      - flake8==5.0.4
      - identify==2.5.24
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.2.0
      - jinja2==3.1.6
      - markupsafe==2.1.5
      - mccabe==0.7.0
      - mypy-extensions==1.0.0
      - nodeenv==1.9.1
      - pathspec==0.11.2
      - platformdirs==2.6.2
      - praw==7.0.1.dev0
      - prawcore==1.5.0
      - pre-commit==2.21.0
      - pycodestyle==2.9.1
      - pydocstyle==6.3.0
      - pyflakes==2.5.0
      - pygments==2.17.2
      - pytest-asyncio==0.21.2
      - pytest-cov==4.1.0
      - pytest-mock==3.11.1
      - pytest-xdist==3.5.0
      - pytz==2025.2
      - pyyaml==6.0.1
      - requests==2.31.0
      - requests-toolbelt==1.0.0
      - snowballstemmer==2.2.0
      - sphinx==2.4.5
      - sphinx-rtd-theme==1.3.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jquery==4.1
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - typed-ast==1.5.5
      - typing-extensions==4.7.1
      - update-checker==0.18.0
      - urllib3==2.0.7
      - virtualenv==20.16.2
      - websocket-client==1.6.1
prefix: /opt/conda/envs/praw

tests/unit/models/reddit/test_subreddit.py::TestSubreddit::test_equality tests/unit/models/reddit/test_subreddit.py::TestSubreddit::test_construct_failure tests/unit/models/reddit/test_subreddit.py::TestSubreddit::test_fullname tests/unit/models/reddit/test_subreddit.py::TestSubreddit::test_hash tests/unit/models/reddit/test_subreddit.py::TestSubreddit::test_invalid_media tests/unit/models/reddit/test_subreddit.py::TestSubreddit::test_pickle tests/unit/models/reddit/test_subreddit.py::TestSubreddit::test_repr tests/unit/models/reddit/test_subreddit.py::TestSubreddit::test_search__params_not_modified tests/unit/models/reddit/test_subreddit.py::TestSubreddit::test_str tests/unit/models/reddit/test_subreddit.py::TestSubreddit::test_submit_failure tests/unit/models/reddit/test_subreddit.py::TestSubreddit::test_upload_banner_additional_image tests/unit/models/reddit/test_subreddit.py::TestSubredditFlair::test_set tests/unit/models/reddit/test_subreddit.py::TestSubredditFlairTemplates::test_not_implemented tests/unit/models/reddit/test_subreddit.py::TestSubredditWiki::test__getitem tests/unit/models/reddit/test_subreddit.py::TestSubredditModmailConversationsStream::test_conversation_stream_init tests/unit/models/reddit/test_subreddit.py::TestSubredditModmailConversationsStream::test_conversation_stream_capilization tests/unit/test_deprecations.py::TestDeprecation::test_validate_on_submit tests/unit/test_deprecations.py::TestDeprecation::test_api_exception tests/unit/test_deprecations.py::TestDeprecation::test_subreddit_rules_call tests/unit/test_deprecations.py::TestDeprecation::test_web_socket_exception_attribute tests/unit/test_exceptions.py::TestPRAWException::test_inheritance tests/unit/test_exceptions.py::TestPRAWException::test_str tests/unit/test_exceptions.py::TestRedditErrorItem::test_equality tests/unit/test_exceptions.py::TestRedditErrorItem::test_property tests/unit/test_exceptions.py::TestRedditErrorItem::test_str tests/unit/test_exceptions.py::TestRedditErrorItem::test_repr tests/unit/test_exceptions.py::TestAPIException::test_catch tests/unit/test_exceptions.py::TestRedditAPIException::test_inheritance tests/unit/test_exceptions.py::TestRedditAPIException::test_items tests/unit/test_exceptions.py::TestRedditAPIException::test_apiexception_value tests/unit/test_exceptions.py::TestClientException::test_inheritance tests/unit/test_exceptions.py::TestClientException::test_str tests/unit/test_exceptions.py::TestDuplicateReplaceException::test_inheritance tests/unit/test_exceptions.py::TestDuplicateReplaceException::test_message tests/unit/test_exceptions.py::TestInvalidFlairTemplateID::test_inheritance tests/unit/test_exceptions.py::TestInvalidFlairTemplateID::test_str tests/unit/test_exceptions.py::TestInvalidImplicitAuth::test_inheritance tests/unit/test_exceptions.py::TestInvalidImplicitAuth::test_message tests/unit/test_exceptions.py::TestInvalidURL::test_inheritance tests/unit/test_exceptions.py::TestInvalidURL::test_message tests/unit/test_exceptions.py::TestInvalidURL::test_custom_message tests/unit/test_exceptions.py::TestMissingRequiredAttributeException::test_inheritance tests/unit/test_exceptions.py::TestMissingRequiredAttributeException::test_str tests/unit/test_exceptions.py::TestWebSocketException::test_inheritance tests/unit/test_exceptions.py::TestWebSocketException::test_str tests/unit/test_exceptions.py::TestWebSocketException::test_exception_attr tests/unit/test_exceptions.py::TestMediaPostFailed::test_inheritance tests/unit/test_exceptions.py::TestMediaPostFailed::test_message
praw/models/reddit/subreddit.py praw/exceptions.py CHANGES.rst
praw/models/reddit/subreddit.py praw/exceptions.py CHANGES.rst