Skip to content

Improve error handling if entity has not been defined on the ContextGraph #182

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

Closed
jaredcnance opened this issue Nov 3, 2017 · 0 comments · Fixed by #195
Closed

Improve error handling if entity has not been defined on the ContextGraph #182

jaredcnance opened this issue Nov 3, 2017 · 0 comments · Fixed by #195

Comments

@jaredcnance
Copy link
Contributor

blows up with:

fail: JsonApiDotNetCore.Middleware.JsonApiExceptionFilter[0]
      An unhandled exception occurred during the request
System.NullReferenceException: Object reference not set to an instance of an object.
   at JsonApiDotNetCore.Services.JsonApiContext.ApplyContext[T](Object controller)
   at JsonApiDotNetCore.Controllers.BaseJsonApiController`2..ctor(IJsonApiContext jsonApiContext, IGetAllService`2 getAll, IGetByIdService`2 getById, IGetRelationshipService`2 getRelationship, IGetRelationshipsService`2 getRelationships, ICreateService`2 create, IUpdateService`2 update, IUpdateRelationshipService`2 updateRelationships, IDeleteService`2 delete)
   at N2JsonApi.Web.Domain.PendingItemChanges.PendingItemChangesController..ctor(IJsonApiContext jsonApiContext, IGetAllService`2 getAll) in /Users/michellesantarsiero/dev/n2-jsonapi/src/N2JsonApi.Web/Domain/PendingItemChanges/PendingItemChangesController.cs:line 20
   at lambda_method(Closure , IServiceProvider , Object[] )
   at Microsoft.AspNetCore.Mvc.Internal.TypeActivatorCache.CreateInstance[TInstance](IServiceProvider serviceProvider, Type implementationType)
   at Microsoft.AspNetCore.Mvc.Controllers.DefaultControllerFactory.CreateController(ControllerContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextExceptionFilterAsync>d__24.MoveNext()

RequestEntity = ContextGraph.GetContextEntity(typeof(T));
if (context.Request.Query.Any())
{
QuerySet = new QuerySet(this, context.Request.Query);
IncludedRelationships = QuerySet.IncludedRelationships;
}
var linkBuilder = new LinkBuilder(this);
BasePath = linkBuilder.GetBasePath(context, RequestEntity.EntityName);

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