Skip to content

use multi-catch in generated code#4021

Merged
filiphr merged 1 commit intomapstruct:mainfrom
hduelme:use-multi-catch-in-generated-code
Mar 23, 2026
Merged

use multi-catch in generated code#4021
filiphr merged 1 commit intomapstruct:mainfrom
hduelme:use-multi-catch-in-generated-code

Conversation

@hduelme
Copy link
Contributor

@hduelme hduelme commented Mar 21, 2026

Since MapStruct requires at least Java 8, multi‑catch can be used in the generated code.
I changed the code in CommonMacros.ftl to use multi‑catch when catching more than one exception, instead of generating multiple catch blocks.
To make this consistent, I replaced the duplicated catch code in Java8FunctionWrapper.ftl and LocalVarWrapper.ftl with the handleExceptions macro.

@filiphr filiphr added this to the 1.7.0.Beta2 milestone Mar 23, 2026
@filiphr filiphr merged commit 0d31049 into mapstruct:main Mar 23, 2026
5 checks passed
@filiphr
Copy link
Member

filiphr commented Mar 23, 2026

Nice improvement @hduelme. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants