Fix error handling for exceptions in the relay server