Browse Source

Exceptions

pull/183/head
Jure Šorn 1 year ago
parent
commit
a55a315972
2 changed files with 6 additions and 4 deletions
  1. 3
      README.md
  2. 7
      index.html

3
README.md

@ -1409,9 +1409,10 @@ except (<exception>, [...]): ...
except (<exception>, [...]) as <name>: ...
```
* **Also catches subclasses of the exception.**
* **Use `'traceback.print_exc()'` to print the error message to stderr.**
* **Use `'traceback.print_exc()'` to print the full error message to stderr.**
* **Use `'print(<name>)'` to print just the cause of the exception (its arguments).**
* **Use `'logging.exception(<message>)'` to log the passed message, followed by the full error message of the caught exception.**
* **Use `'sys.exc_info()'` to get exception type, object and traceback of caught exception.**
### Raising Exceptions
```python

7
index.html

@ -54,7 +54,7 @@
<body>
<header>
<aside>March 15, 2024</aside>
<aside>March 17, 2024</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>
@ -1204,9 +1204,10 @@ LogicOp = Enum(<span class="hljs-string">'LogicOp'</span>, {<span class="hljs-st
<ul>
<li><strong>Also catches subclasses of the exception.</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'traceback.print_exc()'</span></code> to print the error message to stderr.</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'traceback.print_exc()'</span></code> to print the full error message to stderr.</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'print(&lt;name&gt;)'</span></code> to print just the cause of the exception (its arguments).</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'logging.exception(&lt;message&gt;)'</span></code> to log the passed message, followed by the full error message of the caught exception.</strong></li>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'sys.exc_info()'</span></code> to get exception type, object and traceback of caught exception.</strong></li>
</ul>
<div><h3 id="raisingexceptions">Raising Exceptions</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">raise</span> &lt;exception&gt;
<span class="hljs-keyword">raise</span> &lt;exception&gt;()
@ -2934,7 +2935,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the activ
<footer>
<aside>March 15, 2024</aside>
<aside>March 17, 2024</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

Loading…
Cancel
Save