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

Check if file exists before reading it #1

Merged
merged 1 commit into from Dec 18, 2016
Merged

Check if file exists before reading it #1

merged 1 commit into from Dec 18, 2016

Conversation

@Scorfly
Copy link
Contributor

@Scorfly Scorfly commented Dec 17, 2016

No description provided.

@coldfix
Copy link
Member

@coldfix coldfix commented Dec 17, 2016

Hey, I'm a bit worried that this just delays potential errors until the corresponding value is used at some point down the line. If adding this, we should also handle the case that the input variables are nil.

@Scorfly
Copy link
Contributor Author

@Scorfly Scorfly commented Dec 17, 2016

I did this because on my computer one file does not exist :
ac_state = readfile(pre.."/AC/online")

I totally understand your point of view. I'll check to update this later.

@Scorfly
Copy link
Contributor Author

@Scorfly Scorfly commented Dec 18, 2016

I just amended my commit to add check on mandatory values

if a mandatory file is missing the function get_state return nil

i would add a popup/notiffication to inform that a file is missing but https://awesome.naquadah.org does not work any more and every thing i found need to require naughty, so i did not for now

@coldfix
Copy link
Member

@coldfix coldfix commented Dec 18, 2016

This isn't satisfactory either: Assume one of the mandatory files is not found, then get_state returns nil and update crashes on the line text = percent .. "%", indiscriminately of which file wasn't found.

I think there are two options here:

  1. crash immediately for missing "mandatory files" (using the readfile function as is) and only handle ac_state (+others?) differently with a checked function
  2. try as best as we can, and leave out only missing information or in the display (or show, e.g. ???)

What do you prefer?

@Scorfly
Copy link
Contributor Author

@Scorfly Scorfly commented Dec 18, 2016

I amended my commit

in get_state() i checked values but never formated it
in uptdate() I formatted value with Err! if they can not be displayed

@coldfix coldfix merged commit 90f4513 into deficient:master Dec 18, 2016
@coldfix
Copy link
Member

@coldfix coldfix commented Dec 18, 2016

Great thanks.

@ghost ghost mentioned this pull request Jul 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants