-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Provide better exceptions for errors when building the mapping plan #4577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide better exceptions for errors when building the mapping plan #4577
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds better error handling and diagnostic exceptions when building mapping strategies in AutoMapper. The change wraps critical mapping operations in try-catch blocks to provide more informative exceptions when expression tree building fails.
- Wraps mapping operations in try-catch blocks to catch and re-throw as
AutoMapperMappingException - Adds context-specific error messages for different mapping scenarios
- Covers both in-memory mapping strategies and LINQ projection mapping
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/AutoMapper/TypeMap.cs | Adds exception handling around type map sealing and expression creation |
| src/AutoMapper/QueryableExtensions/ProjectionBuilder.cs | Adds exception handling for property projections and constructor parameter mapping in LINQ scenarios |
| src/AutoMapper/Execution/TypeMapPlanBuilder.cs | Adds exception handling for path maps, property maps, and constructor parameter mapping in execution plans |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This PR adds diagnostic exceptions around mapping individual members. If there's an exception building the expression trees there's not details given from those exceptions.
This covers:
Fixes #4558, #4563