How to detect XrootD error and protect the output

In that case, you will need to use your own error message handler (to be able to check the message and do the ‘right’ thing).

  gROOT->SetErrorHandler(CustomErrorHandler);

You can see the default version of this function at: ROOT: core/base/src/TErrorDefaultHandler.cxx Source File