Skip to content

all: Tweak error creation - #6391

Merged
calmh merged 3 commits into
syncthing:masterfrom
calmh:1.13errors
Mar 3, 2020
Merged

calmh merged 3 commits into
syncthing:masterfrom
calmh:1.13errors

Conversation

@calmh

@calmh calmh commented Mar 1, 2020

Copy link
Copy Markdown
Member
  • In the few places where we wrap errors, use the new Go 1.13 "%w"
    construction instead of %s or %v.

  • Where we create errors with constant strings, consistently use
    errors.New and not fmt.Errorf.

  • Remove capitalization from errors in the few places where we had that.

calmh added 2 commits March 1, 2020 13:20
- In the few places where we wrap errors, use the new Go 1.13 "%w"
  construction instead of %s or %v.

- Where we create errors with constant strings, consistently use
  errors.New and not fmt.Errorf.

- Remove capitalization from errors in the few places where we had that.
Comment thread lib/rc/rc.go Outdated
err = dec.Decode(&evs)
if err != nil {
return nil, fmt.Errorf("Events: %s in %q", err, bs)
return nil, fmt.Errorf("events: %s in %q", err, bs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%w?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires turning the error around, %w only works as the last verb. This is internal so I didn't bother.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"only works with last verb" lol wat.

@calmh calmh Mar 1, 2020 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to be:

If the last argument is an error and the format string ends with ": %w", the returned error implements an Unwrap method returning it. (https://godoc.org/golang.org/x/xerrors#Errorf)

apparently that was relaxed in the final implementation

@calmh
calmh merged commit dd92b2b into syncthing:master Mar 3, 2020
@calmh
calmh deleted the 1.13errors branch March 6, 2020 10:20
@calmh calmh added this to the v1.4.1 milestone Mar 6, 2020
calmh added a commit to calmh/syncthing that referenced this pull request Mar 7, 2020
* master: (64 commits)
  lib/db: Be more lenient during migration (fixes syncthing#6397) (syncthing#6398)
  lib/db: Be more lenient during migration (fixes syncthing#6397) (syncthing#6398)
  cmd/ursrv: Analytics for Synology dist
  build: Build image should use Go 1.13 for now
  gui, lib/api: Remove CPU & RAM measurements (fixes syncthing#6249) (syncthing#6393)
  gui, man, authors: Update docs, translations, and contributors
  all: Tweak error creation (syncthing#6391)
  authors: Cleanup on request
  build: We can now use Go 1.13
  lib/db: Prevent GC concurrently with migration (fixes syncthing#6389) (syncthing#6390)
  lib/db: Prevent GC concurrently with migration (fixes syncthing#6389) (syncthing#6390)
  build: Fix syso creation (fixes syncthing#6386) (syncthing#6387)
  build: Fix syso creation (fixes syncthing#6386) (syncthing#6387)
  lib/db: Correct metadata recalculation (fixes syncthing#6381) (syncthing#6382)
  lib/db: Correct metadata recalculation (fixes syncthing#6381) (syncthing#6382)
  lib/db: Remove reference to env var that never existed
  lib/db: Slightly improve indirection (ref syncthing#6372) (syncthing#6373)
  lib/db: Remove reference to env var that never existed
  lib/db: Slightly improve indirection (ref syncthing#6372) (syncthing#6373)
  build: Forked github.com/spaolacci/murmur3 for unsafe (ref syncthing#6371)
  ...
calmh added a commit to calmh/syncthing that referenced this pull request Mar 7, 2020
* master: (64 commits)
  lib/db: Be more lenient during migration (fixes syncthing#6397) (syncthing#6398)
  lib/db: Be more lenient during migration (fixes syncthing#6397) (syncthing#6398)
  cmd/ursrv: Analytics for Synology dist
  build: Build image should use Go 1.13 for now
  gui, lib/api: Remove CPU & RAM measurements (fixes syncthing#6249) (syncthing#6393)
  gui, man, authors: Update docs, translations, and contributors
  all: Tweak error creation (syncthing#6391)
  authors: Cleanup on request
  build: We can now use Go 1.13
  lib/db: Prevent GC concurrently with migration (fixes syncthing#6389) (syncthing#6390)
  lib/db: Prevent GC concurrently with migration (fixes syncthing#6389) (syncthing#6390)
  build: Fix syso creation (fixes syncthing#6386) (syncthing#6387)
  build: Fix syso creation (fixes syncthing#6386) (syncthing#6387)
  lib/db: Correct metadata recalculation (fixes syncthing#6381) (syncthing#6382)
  lib/db: Correct metadata recalculation (fixes syncthing#6381) (syncthing#6382)
  lib/db: Remove reference to env var that never existed
  lib/db: Slightly improve indirection (ref syncthing#6372) (syncthing#6373)
  lib/db: Remove reference to env var that never existed
  lib/db: Slightly improve indirection (ref syncthing#6372) (syncthing#6373)
  build: Forked github.com/spaolacci/murmur3 for unsafe (ref syncthing#6371)
  ...
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Mar 4, 2021
@syncthing syncthing locked and limited conversation to collaborators Mar 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants