Refactoring common code to functions
Refactoring common code to functions

Moved all the exception generating parts to their own functions. That
way all the CRUD functions do a small sanity check first which anyway
bubbles up the exceptions so the code redundancy is reduced.

Dunno if this is the right way to do it. But let it run for now.

shrayasr/PCache