When in a pl/pgsql function there is an exception then the function stops the execution and returns an error.
When this happens all the changes made are rolled back.
It’s always possible to manage the error at application level, however there are some cases where managing the exception inside the function it may be a sensible choice.
And pl/pgsql have a nice way to do that. The EXCEPTION block.
However handling the exception inside a function is not just a cosmetic thing.
The way the excepion is handled have implications that may cause issues.