SSHOC / sshoc-marketplace-backend

Code for the backend
Apache License 2.0
2 stars 0 forks source link

Catch error when an item is not found #165

Closed dpancic closed 1 year ago

dpancic commented 2 years ago

In GitLab by @KlausIllmayer on Apr 5, 2022, 12:21

Currently, when you try to call a non-existing items, non-existing versions of an item or not (more) existing draft items, this raises an error in the logfiles, here are some of these errors:

ERROR e.s.m.c.MarketplaceExceptionHandler.handleEntityNotFoundException - No entity
javax.persistence.EntityNotFoundException: Unable to find eu.sshopencloud.marketplace.model.tools.Tool with id AOHiq8 and version id 407023
    at eu.sshopencloud.marketplace.services.items.ItemVersionService.lambda$loadItemVersion$5(ItemVersionService.java:155)
ERROR e.s.m.c.MarketplaceExceptionHandler.handleEntityNotFoundException - No entity
javax.persistence.EntityNotFoundException: Unable to find draft eu.sshopencloud.marketplace.model.publications.Publication with id C2BbdX for the authorized user
    at eu.sshopencloud.marketplace.services.items.ItemVersionService.lambda$loadItemDraftForCurrentUser$2(ItemVersionService.java:124)

At least the last error is raised quite often, as frontend needs to look for a possible draft verison of an item if a logged user edits an item. The "no entity" information is interesting but I wouldn't qualify it as an error.

@tparkola Do you think you could catch these errors and instead of raising an error with the full callback debug information give only a simple INFO line in the logfiles (e.g. the "Unable to find [category] with id [persistent_id] and version id [version_id]" not as exception but as info line)?

dpancic commented 2 years ago

In GitLab by @tparkola on Apr 22, 2022, 13:37

I looked into it, in one case I can change into logFile but in other no. Function must return something, either Optional.Empty() or null. But because the result is then processed by further function, the nullPointerException will occur. One way or another the response must be sent.

dpancic commented 2 years ago

In GitLab by @KlausIllmayer on Jun 28, 2022, 14:33

Unfortunately, this seems to be not possible to solve.