Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TFile's ctor's error message should point to TFile::Open when filename contains "://" #10039

Open
eguiraud opened this issue Mar 3, 2022 · 2 comments

Comments

@eguiraud
Copy link
Member

@eguiraud eguiraud commented Mar 3, 2022

Current behavior:

root [0] TFile f("root://eospublic.cern.ch//eos/root-eos/benchmark/Run2012B_SingleMu.root")
Error in <TFile::TFile>: file /eos/root-eos/benchmark/Run2012B_SingleMu.root does not exist
(TFile &) Name: /eos/root-eos/benchmark/Run2012B_SingleMu.root Title:

Desirable behavior:

root [0] TFile f("root://eospublic.cern.ch//eos/root-eos/benchmark/Run2012B_SingleMu.root")
Error in <TFile::TFile>: please use TFile::Open to access remote files:
    auto f = std::unique_ptr<TFile>{TFile::Open("root://eospublic.cern.ch//eos/root-eos/benchmark/Run2012B_SingleMu.root")} 
(TFile &) Name: /eos/root-eos/benchmark/Run2012B_SingleMu.root Title:
@Harshalzzzzzzz
Copy link
Contributor

@Harshalzzzzzzz Harshalzzzzzzz commented Apr 7, 2022

@eguiraud Sir would like to work on this issue. Can you please elaborate more on what needs to be done?
Thanks!

@eguiraud
Copy link
Member Author

@eguiraud eguiraud commented Apr 7, 2022

Hello @Harshalzzzzzzz ,
basically what the description says: currently, if you construct a TFile directly (i.e. not going through the factory function TFile::Open) the constructor errors out if some protocol must be used to access the file (e.g. root:// or http://) -- like in the first example in the description. The reason why this does not work is not very important, the point is that TFile("root://...") fails and the right thing to do instead is TFile::Open("root://...").

So if the TFile constructor fails with that "file ... does not exist" error, before printing that error we want to check whether the filename contains "://" and if it does we want to print a different error message that does not say "file ... does not exist" but instead it points users to using "TFile::Open" instead (as in the issue description).

You can use a debugger or grep the source code for the error message text to see where the relevant logic resides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants