Skip to content

Commit d5e1365

Browse files
authored
Merge pull request #155 from rjmurillo/hotfix/8.0.1
Catch `DeniedOrNotExistException` when accessing field during map
2 parents 9224180 + d873382 commit d5e1365

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Qwiq.Mapper/Attributes/AttributeMapperStrategy.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,18 @@ protected internal virtual void MapImpl(Type targetWorkItemType, IWorkItem sourc
133133
var fieldName = a.FieldName;
134134
var convert = a.RequireConversion;
135135
var nullSub = a.NullSubstitute;
136-
var fieldValue = sourceWorkItem[fieldName];
136+
object fieldValue;
137+
try
138+
{
139+
fieldValue = sourceWorkItem[fieldName];
140+
}
141+
catch (DeniedOrNotExistException e)
142+
{
143+
var tm = new TypePair(sourceWorkItem, targetWorkItemType);
144+
var pm = new PropertyMap(property, fieldName);
145+
var message = $"Unable to get field value on {sourceWorkItem.Id}.";
146+
throw new AttributeMapException(message, e, tm, pm);
147+
}
137148

138149
AssignFieldValue(targetWorkItemType, sourceWorkItem, targetWorkItem, property, fieldName, convert, nullSub, fieldValue);
139150
}

0 commit comments

Comments
 (0)