Make pass-by-ref arguments const.

Make some of the arguments in rest.cpp, that are passed by
reference but never modified, const to emphasise that.
make all catch() arguments const

- I saw this on http://en.cppreference.com/w/cpp/language/try_catch and
  thought it would be a good idea
- also unify used format to better be able to search for exception
  uses in our codebase
Merge pull request #5438

27df412 make all catch() arguments const (Philip Kaufmann)
Merge pull request #5484

7c8e4c5 Make pass-by-ref arguments const. (Daniel Kraft)