Catch all REST exceptions.

This fixes issue 1738.