callumbwhyte / meganav

A flexible, draggable link picker for constructing site navigation menus in Umbraco
MIT License
35 stars 34 forks source link

MeganavEntityApiController throws exception when linked content is deleted #39

Closed ronaldbarendse closed 2 years ago

ronaldbarendse commented 5 years ago

The API controller currently throws the following exception when a non-existent entity ID is requested (deleted from recycle bin), e.g. /umbraco/backoffice/Meganav/MeganavEntityApi/GetById?id=0: System.InvalidOperationException: A null value was returned where an instance of HttpResponseMessage was expected..

This could be fixed by changing the following line: https://github.com/thecogworks/meganav/blob/efae678daa1c7898f67926234ac7419a69a494dc/src/Cogworks.Meganav/Web/Controllers/API/MeganavApiController.cs#L28 to

return this.NotFound();

The AngularJS controller could even be updated to report these items (like with unpublished items) or even automatically remove them...

mzajkowski commented 5 years ago

@ronaldbarendse great finding! Can you submit a PR with this change?

callumbwhyte commented 2 years ago

Closing as this controller is now gone in V2 / V3 of Meganav.