88using System . Web . Http ;
99using JSONAPI . ActionFilters ;
1010using JSONAPI . Core ;
11+ using JSONAPI . Documents . Builders ;
1112
1213namespace JSONAPI . QueryableTransformers
1314{
@@ -79,11 +80,14 @@ private Expression GetPredicateBody(HttpRequestMessage request, ParameterExpress
7980 }
8081 catch ( TypeRegistrationNotFoundException )
8182 {
82- throw new HttpResponseException ( HttpStatusCode . BadRequest ) ;
83+ throw JsonApiException . CreateForBadRequest ( "No registration exists for the specified type" ) ;
8384 }
8485
8586 var resourceTypeField = registration . GetFieldByName ( filterField ) ;
86-
87+ if ( resourceTypeField == null )
88+ throw JsonApiException . CreateForBadRequest (
89+ string . Format ( "No attribute {0} exists on the specified type." , filterField ) ) ;
90+
8791 var queryValue = queryPair . Value ;
8892 if ( string . IsNullOrWhiteSpace ( queryValue ) )
8993 queryValue = null ;
@@ -100,7 +104,8 @@ private Expression GetPredicateBody(HttpRequestMessage request, ParameterExpress
100104 if ( relationshipModelProperty != null )
101105 expr = GetPredicateBodyForRelationship ( relationshipModelProperty , queryValue , param ) ;
102106
103- if ( expr == null ) throw new HttpResponseException ( HttpStatusCode . BadRequest ) ;
107+ if ( expr == null ) throw JsonApiException . CreateForBadRequest (
108+ string . Format ( "The attribute {0} is unsupported for filtering." , filterField ) ) ;
104109
105110 workingExpr = workingExpr == null ? expr : Expression . AndAlso ( workingExpr , expr ) ;
106111 }
@@ -344,7 +349,7 @@ private Expression GetPredicateBodyForRelationship(ResourceTypeRelationship reso
344349 }
345350 catch ( TypeRegistrationNotFoundException )
346351 {
347- throw new HttpResponseException ( HttpStatusCode . BadRequest ) ;
352+ throw JsonApiException . CreateForBadRequest ( "No registration exists for the specified type" ) ;
348353 }
349354
350355 var prop = resourceTypeProperty . Property ;
0 commit comments