Bug 205394

Summary: Make new Language module more error-resistant
Product: [openSUSE] openSUSE 10.2 Reporter: Lukas Ocilka <locilka>
Component: YaST2Assignee: Jiří Suchomel <jsuchome>
Status: RESOLVED INVALID QA Contact: Jiri Srain <jsrain>
Severity: Enhancement    
Priority: P5 - None CC: andreas.hanke
Version: Alpha 4   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: y2log.gz

Description Lukas Ocilka 2006-09-13 09:53:51 UTC
I've used the Language module for my own 'Alpha4+' ;) and because I haven't copied new languages definitions on the right place.

SystemAgent.cc(Read):544 Can't access directory '/usr/share/YaST2/data/languages': No such file or directory'
Language.ycp:144 Argument (/* any -> list <string> */SCR::Read (.target.dir, languages_directory, [])) to foreach(...) is nil

Please, add a check for 'nil' there (or any other similar check).
Thanks
Comment 1 Lukas Ocilka 2006-09-13 09:54:34 UTC
Created attachment 98557 [details]
y2log.gz
Comment 2 Jiří Suchomel 2006-09-13 10:35:34 UTC
You have to use correct yast2-country package. I assume you got the empty map as a result anyway, not nil.
Comment 3 Lukas Ocilka 2006-09-13 11:32:33 UTC
You cannot assume that everything is OK when loading data from SCR, it rather seems that the module internally expects that everything goes all right. On the other hand, if you don't care, just ignore it.

--- this ---
Language.ycp:144 Argument (/* any -> list <string> */SCR::Read (.target.dir,
languages_directory, [])) to foreach(...) is nil

is incorrect code, but if you don't care, I don't either...
Comment 4 Jiří Suchomel 2006-09-13 11:37:36 UTC
> seems that the module internally expects that everything goes all right

Not really. Did you get wrong result from your function?

The module just expects it is correctly installed, which is quite ususal expectation, I think. And even if you break your /usr/share/YaST2/data/languages directory manually, the function doesn't return wrong result.
Comment 5 Lukas Ocilka 2006-09-13 11:44:15 UTC
It's always a matter of opinion :) ;)

I'd say that if part of code reports "Argument ... to foreach(...) is nil", then it is a mistake, that this exception is not handled before. It doesn't matter than the function than returns correct data.

The correct could be:
... = (...) SCR::Read() / SCR::Dir();
if (... == nil) y2error ("some error message");
else ...