Skip to content

Commit c1ad668

Browse files
authored
Added Exceptions section below the Example Code Example
Signed-off-by: BartyBoi1128 <[email protected]>
1 parent a1e4cd1 commit c1ad668

File tree

1 file changed

+7
-7
lines changed
  • docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-390

1 file changed

+7
-7
lines changed

docs/Secure-Coding-Guide-for-Python/CWE-703/CWE-390/REAME.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,6 @@ def exception_example():
8686
exception_example()
8787
```
8888

89-
## Exceptions
90-
91-
The following two exceptions, highlighted in [SEI Cert's Oracle Coding Standard for Java](https://wiki.sei.cmu.edu/confluence/display/java/SEI+CERT+Oracle+Coding+Standard+for+Java), are important to understand when to attempt to handle exceptions at the right level in the stack in Python also.
92-
93-
* __ERR00-J-EX0:__ You may suppress exceptions during the release of non-reusable resources, such as closing files, network sockets, or shutting down threads, if they don't affect future program behavior.
94-
* __ERR00-J-EX1:__ Allow higher-level code to catch and attempt recovery from exceptions. If recovery is not possible, log the exception, add information if needed, and rethrow it.
95-
9689
## Example Code Example
9790

9891
If recovery from an exception remains impossible, it is often best practice to wrap the checked exception in an unchecked exception and rethrow it. This approach allows the application to fail gracefully or log the error for future debugging, rather than crashing unexpectedly.
@@ -130,6 +123,13 @@ def slice_cake(cake: int, plates: int) -> float:
130123
slice_cake(cake=100, plates=0)
131124
```
132125

126+
## Exceptions
127+
128+
The following two exceptions, highlighted in [SEI Cert's Oracle Coding Standard for Java](https://wiki.sei.cmu.edu/confluence/display/java/SEI+CERT+Oracle+Coding+Standard+for+Java), are important to understand when to attempt to handle exceptions at the right level in the stack in Python also.
129+
130+
* __ERR00-J-EX0:__ You may suppress exceptions during the release of non-reusable resources, such as closing files, network sockets, or shutting down threads, if they don't affect future program behavior.
131+
* __ERR00-J-EX1:__ Allow higher-level code to catch and attempt recovery from exceptions. If recovery is not possible, log the exception, add information if needed, and rethrow it.
132+
133133
## Automated Detection
134134

135135
|Tool|Version|Checker|Description|

0 commit comments

Comments
 (0)