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

time: loadZoneFile() doesn't forward error returned while reading zoneinfo file. #9723

Closed
ksaket opened this issue Jan 29, 2015 · 2 comments
Closed
Assignees

Comments

@ksaket
Copy link

@ksaket ksaket commented Jan 29, 2015

Loading ZoneInfo accesses disk which can fail for various reasons. The method time.loadZoneFile() does not expose these errors to time.LoadLocation(). Hence, it reports a generic "unknown time zone" error as an effect to such failures.

https://golang.org/src/time/zoneinfo_unix.go

@dsymonds: who is aware of this problem.

@dsymonds dsymonds self-assigned this Jan 29, 2015
@dsymonds
Copy link
Member

@dsymonds dsymonds commented Jan 29, 2015

I think this is an issue because loadZoneFile is swallowing error details too much. The most common failure mode for any particular attempt in that function is to get a file not found, which is fine to suppress, but other kinds of errors should be reported back so that callers to time.LoadLocation can discover why it's failing.

Here's my proposal:

  • if loadZoneFile finds a file it can successfully load, it reports no error (current behaviour)
  • if no file can be loaded, and there's an error that does not satisfy os.IsNotExist, report that error (new behaviour)
  • if all the errors satisfy os.IsNotExist, report the generic message (current behaviour)

@rsc, does that sound okay to you?

@mikioh mikioh changed the title time.loadZoneFile() doesn't forward error returned while reading zoneinfo file. time: loadZoneFile() doesn't forward error returned while reading zoneinfo file. Jan 30, 2015
@dsymonds
Copy link
Member

@dsymonds dsymonds commented Feb 6, 2015

@dsymonds dsymonds closed this in 8bf1383 Feb 8, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.