Skip to content

Flatten-Nested-Try

Documentation Index

Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt

Use this file to discover all available pages before exploring further.

Merge nested try-statement into a single try

try {
try {
something()
} catch (e) {
catching()
}
} finally {
finalling()
}
try {
something()
} catch (e) {
catching()
} finally {
finalling()
}

Flattening try…catch statements nested within a try…finally generates equivalent code that is easier to read and expand upon.