There could be a few reasons for this, depending on your version and the details of the stock movement. A few things to check:
Based on the error message, you may have to upgrade your permissions. Any permission manager or above should be able to delete a pending stock movement, but there was an issue with this in a few releases before it was patched. If you are in one of those versions, you may need to be an admin to delete pending objects.
If your shipment is shipped, you need to roll it back before deleting. This requires admin or superuser permissions depending on your version (more recent versions require admin only). In this case there should be an in-app validation message, but its possible that validation is broken
The location you are in matters when deleting shipments. If it is a shipment originating from a depot within the system, you need to be in that depot to delete it. If it is a shipment originating from a location outside the system (like a vendor) you need to be in the destination depot to delete it. These restrictions are attempting to prevent people from deleting shipments that are relevant to other managed depots. This is another restriction that should give a clear validation error rather than a 500 error, but its possible that the error message isnt working properly.
These are the most likely causes. If none of them apply, could you give some more information about the shipment and reproduction steps? That may help identify other potential causes.