>> Great, looks good to me, marking as ready for committer.
What is wrong with using IF ?
It significantly increase code' length .. and decrease readability when you intensive use a pattern IF THEN RAISE END IF - when you check every parameter, when you check every result.
RAISE ... WHEN ... is shorter with full power of RAISE statement and possibility for future enhancing.