Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2017-03-21 13:45:17 +0300
committerJacob Vosmaer <jacob@gitlab.com>2017-03-21 13:45:17 +0300
commitf9f49a3314f467cb5a4f81162b34bcc6aa042d86 (patch)
treea83b8ab9c9a4e1af158caeb1e0704479c42dfb83
parente52897f76ca0459f3992583435994c3cced805cc (diff)
More error style guidelines
-rw-r--r--STYLE.md28
1 files changed, 27 insertions, 1 deletions
diff --git a/STYLE.md b/STYLE.md
index f2e77c11e..fc76b1a8f 100644
--- a/STYLE.md
+++ b/STYLE.md
@@ -6,7 +6,33 @@
Use `%v` when wrapping errors with context.
- return fmt.Errorf("foo context: %v", err)
+ fmt.Errorf("foo context: %v", err)
+
+### Keep errors short
+
+It is customary in Go to pass errors up the call stack and decorate
+them. To be a good neighbor to the rest of the call stack we should keep
+our errors short.
+
+ // Good
+ fmt.Errorf("peek diff line: %v", err)
+
+ // Too long
+ fmt.Errorf("ParseDiffOutput: Unexpected error while peeking: %v", err)
+
+### Use lower case in errors
+
+Use lower case in errors; it is OK to preserve upper case in names.
+
+### Errors should stick to the facts
+
+It is tempting to write errors that explain the problem that occurred.
+This can be appropriate in some end-user facing situations, but it is
+never appropriate for internal error messages. When your
+interpretation is wrong it puts the reader on the wrong track.
+
+Stick to the facts. Often it is enough to just describe in a few words
+what we were trying to do.
### Use %q when interpolating strings