@@ -66,9 +66,9 @@ private void ConvertAttribute(IIdentifiable resource, string attributeName, obje
66
66
67
67
AssertIsKnownAttribute ( attr , attributeName , resourceContext , state ) ;
68
68
AssertNoInvalidAttribute ( attributeValue , state ) ;
69
- AssertNoBlockedCreate ( attr , state ) ;
70
- AssertNoBlockedChange ( attr , state ) ;
71
- AssertNotReadOnly ( attr , state ) ;
69
+ AssertNoBlockedCreate ( attr , resourceContext , state ) ;
70
+ AssertNoBlockedChange ( attr , resourceContext , state ) ;
71
+ AssertNotReadOnly ( attr , resourceContext , state ) ;
72
72
73
73
attr ! . SetValue ( resource , attributeValue ) ;
74
74
state . WritableTargetedFields . Attributes . Add ( attr ) ;
@@ -90,7 +90,7 @@ private static void AssertNoInvalidAttribute(object attributeValue, RequestAdapt
90
90
{
91
91
if ( info == JsonInvalidAttributeInfo . Id )
92
92
{
93
- throw new DeserializationException ( state . Position , null , "Resource ID is read-only." ) ;
93
+ throw new ModelConversionException ( state . Position , "Resource ID is read-only." , null ) ;
94
94
}
95
95
96
96
string typeName = info . AttributeType . GetFriendlyTypeName ( ) ;
@@ -100,29 +100,30 @@ private static void AssertNoInvalidAttribute(object attributeValue, RequestAdapt
100
100
}
101
101
}
102
102
103
- private static void AssertNoBlockedCreate ( AttrAttribute attr , RequestAdapterState state )
103
+ private static void AssertNoBlockedCreate ( AttrAttribute attr , ResourceContext resourceContext , RequestAdapterState state )
104
104
{
105
105
if ( state . Request . WriteOperation == WriteOperationKind . CreateResource && ! attr . Capabilities . HasFlag ( AttrCapabilities . AllowCreate ) )
106
106
{
107
- throw new DeserializationException ( state . Position , "Setting the initial value of the requested attribute is not allowed ." ,
108
- $ "Setting the initial value of ' { attr . PublicName } ' is not allowed .") ;
107
+ throw new ModelConversionException ( state . Position , "Attribute value cannot be assigned when creating resource ." ,
108
+ $ "The attribute ' { attr . PublicName } ' on resource type ' { resourceContext . PublicName } ' cannot be assigned to .") ;
109
109
}
110
110
}
111
111
112
- private static void AssertNoBlockedChange ( AttrAttribute attr , RequestAdapterState state )
112
+ private static void AssertNoBlockedChange ( AttrAttribute attr , ResourceContext resourceContext , RequestAdapterState state )
113
113
{
114
114
if ( state . Request . WriteOperation == WriteOperationKind . UpdateResource && ! attr . Capabilities . HasFlag ( AttrCapabilities . AllowChange ) )
115
115
{
116
- throw new DeserializationException ( state . Position , "Changing the value of the requested attribute is not allowed ." ,
117
- $ "Changing the value of ' { attr . PublicName } ' is not allowed .") ;
116
+ throw new ModelConversionException ( state . Position , "Attribute value cannot be assigned when updating resource ." ,
117
+ $ "The attribute ' { attr . PublicName } ' on resource type ' { resourceContext . PublicName } ' cannot be assigned to .") ;
118
118
}
119
119
}
120
120
121
- private static void AssertNotReadOnly ( AttrAttribute attr , RequestAdapterState state )
121
+ private static void AssertNotReadOnly ( AttrAttribute attr , ResourceContext resourceContext , RequestAdapterState state )
122
122
{
123
123
if ( attr . Property . SetMethod == null )
124
124
{
125
- throw new DeserializationException ( state . Position , "Attribute is read-only." , $ "Attribute '{ attr . PublicName } ' is read-only.") ;
125
+ throw new ModelConversionException ( state . Position , "Attribute is read-only." ,
126
+ $ "Attribute '{ attr . PublicName } ' on resource type '{ resourceContext . PublicName } ' is read-only.") ;
126
127
}
127
128
}
128
129
0 commit comments