From 295fa1ca99282954e6d6f6459fe692c9b75812ee Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Thu, 15 Jan 2015 11:49:41 -0800 Subject: [PATCH 1/2] error: deprecate unused error code --- error/error.go | 52 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/error/error.go b/error/error.go index 33367f73f..7fb18f871 100644 --- a/error/error.go +++ b/error/error.go @@ -27,24 +27,24 @@ var errors = map[int]string{ EcodeKeyNotFound: "Key not found", EcodeTestFailed: "Compare failed", //test and set EcodeNotFile: "Not a file", - EcodeNoMorePeer: "Reached the max number of peers in the cluster", + ecodeNoMorePeer: "Reached the max number of peers in the cluster", EcodeNotDir: "Not a directory", EcodeNodeExist: "Key already exists", // create EcodeRootROnly: "Root is read only", - EcodeKeyIsPreserved: "The prefix of given key is a keyword in etcd", + ecodeKeyIsPreserved: "The prefix of given key is a keyword in etcd", EcodeDirNotEmpty: "Directory not empty", - EcodeExistingPeerAddr: "Peer address has existed", + ecodeExistingPeerAddr: "Peer address has existed", // Post form related errors - EcodeValueRequired: "Value is Required in POST form", + ecodeValueRequired: "Value is Required in POST form", EcodePrevValueRequired: "PrevValue is Required in POST form", EcodeTTLNaN: "The given TTL in POST form is not a number", EcodeIndexNaN: "The given index in POST form is not a number", - EcodeValueOrTTLRequired: "Value or TTL is required in POST form", - EcodeTimeoutNaN: "The given timeout in POST form is not a number", - EcodeNameRequired: "Name is required in POST form", - EcodeIndexOrValueRequired: "Index or value is required", - EcodeIndexValueMutex: "Index and value cannot both be specified", + ecodeValueOrTTLRequired: "Value or TTL is required in POST form", + ecodeTimeoutNaN: "The given timeout in POST form is not a number", + ecodeNameRequired: "Name is required in POST form", + ecodeIndexOrValueRequired: "Index or value is required", + ecodeIndexValueMutex: "Index and value cannot both be specified", EcodeInvalidField: "Invalid field", EcodeInvalidForm: "Invalid POST form", @@ -55,12 +55,12 @@ var errors = map[int]string{ // etcd related errors EcodeWatcherCleared: "watcher is cleared due to etcd recovery", EcodeEventIndexCleared: "The event in requested index is outdated and cleared", - EcodeStandbyInternal: "Standby Internal Error", - EcodeInvalidActiveSize: "Invalid active size", - EcodeInvalidRemoveDelay: "Standby remove delay", + ecodeStandbyInternal: "Standby Internal Error", + ecodeInvalidActiveSize: "Invalid active size", + ecodeInvalidRemoveDelay: "Standby remove delay", // client related errors - EcodeClientInternal: "Client Internal Error", + ecodeClientInternal: "Client Internal Error", } var errorStatus = map[int]int{ @@ -77,23 +77,23 @@ const ( EcodeKeyNotFound = 100 EcodeTestFailed = 101 EcodeNotFile = 102 - EcodeNoMorePeer = 103 + ecodeNoMorePeer = 103 EcodeNotDir = 104 EcodeNodeExist = 105 - EcodeKeyIsPreserved = 106 + ecodeKeyIsPreserved = 106 EcodeRootROnly = 107 EcodeDirNotEmpty = 108 - EcodeExistingPeerAddr = 109 + ecodeExistingPeerAddr = 109 - EcodeValueRequired = 200 + ecodeValueRequired = 200 EcodePrevValueRequired = 201 EcodeTTLNaN = 202 EcodeIndexNaN = 203 - EcodeValueOrTTLRequired = 204 - EcodeTimeoutNaN = 205 - EcodeNameRequired = 206 - EcodeIndexOrValueRequired = 207 - EcodeIndexValueMutex = 208 + ecodeValueOrTTLRequired = 204 + ecodeTimeoutNaN = 205 + ecodeNameRequired = 206 + ecodeIndexOrValueRequired = 207 + ecodeIndexValueMutex = 208 EcodeInvalidField = 209 EcodeInvalidForm = 210 @@ -102,11 +102,11 @@ const ( EcodeWatcherCleared = 400 EcodeEventIndexCleared = 401 - EcodeStandbyInternal = 402 - EcodeInvalidActiveSize = 403 - EcodeInvalidRemoveDelay = 404 + ecodeStandbyInternal = 402 + ecodeInvalidActiveSize = 403 + ecodeInvalidRemoveDelay = 404 - EcodeClientInternal = 500 + ecodeClientInternal = 500 ) type Error struct { From e8698b0e421a30a5bfa8baddadde59797f15abd0 Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Thu, 15 Jan 2015 12:04:51 -0800 Subject: [PATCH 2/2] docs: update errorcode.md --- Documentation/errorcode.md | 80 +++++++++++++++----------------------- error/error.go | 5 ++- 2 files changed, 35 insertions(+), 50 deletions(-) diff --git a/Documentation/errorcode.md b/Documentation/errorcode.md index b48397353..5951dcd1d 100644 --- a/Documentation/errorcode.md +++ b/Documentation/errorcode.md @@ -1,60 +1,42 @@ Error Code ====== -This document describes the error code in **Etcd** project. +This document describes the error code used in key space '/v2/keys'. Feel free to import 'github.com/coreos/etcd/error' to use. It's categorized into four groups: - Command Related Error + +| name | code | strerror | +|----------------------|------|-----------------------| +| EcodeKeyNotFound | 100 | "Key not found" | +| EcodeTestFailed | 101 | "Compare failed" | +| EcodeNotFile | 102 | "Not a file" | +| EcodeNotDir | 104 | "Not a directory" | +| EcodeNodeExist | 105 | "Key already exists" | +| EcodeRootROnly | 107 | "Root is read only" | +| EcodeDirNotEmpty | 108 | "Directory not empty" | + - Post Form Related Error + +| name | code | strerror | +|--------------------------|------|------------------------------------------------| +| EcodePrevValueRequired | 201 | "PrevValue is Required in POST form" | +| EcodeTTLNaN | 202 | "The given TTL in POST form is not a number" | +| EcodeIndexNaN | 203 | "The given index in POST form is not a number" | +| EcodeInvalidField | 209 | "Invalid field" | +| EcodeInvalidForm | 210 | "Invalid POST form" | + - Raft Related Error + +| name | code | strerror | +|-------------------|------|--------------------------| +| EcodeRaftInternal | 300 | "Raft Internal Error" | +| EcodeLeaderElect | 301 | "During Leader Election" | + - Etcd Related Error -Error code corresponding strerror ------- - - const ( - EcodeKeyNotFound = 100 - EcodeTestFailed = 101 - EcodeNotFile = 102 - EcodeNoMorePeer = 103 - EcodeNotDir = 104 - EcodeNodeExist = 105 - EcodeKeyIsPreserved = 106 - EcodeRootROnly = 107 - - EcodeValueRequired = 200 - EcodePrevValueRequired = 201 - EcodeTTLNaN = 202 - EcodeIndexNaN = 203 - - EcodeRaftInternal = 300 - EcodeLeaderElect = 301 - - EcodeWatcherCleared = 400 - EcodeEventIndexCleared = 401 - ) - - // command related errors - errors[100] = "Key Not Found" - errors[101] = "Test Failed" //test and set - errors[102] = "Not A File" - errors[103] = "Reached the max number of peers in the cluster" - errors[104] = "Not A Directory" - errors[105] = "Already exists" // create - errors[106] = "The prefix of given key is a keyword in etcd" - errors[107] = "Root is read only" - - // Post form related errors - errors[200] = "Value is Required in POST form" - errors[201] = "PrevValue is Required in POST form" - errors[202] = "The given TTL in POST form is not a number" - errors[203] = "The given index in POST form is not a number" - - // raft related errors - errors[300] = "Raft Internal Error" - errors[301] = "During Leader Election" - - // etcd related errors - errors[400] = "watcher is cleared due to etcd recovery" - errors[401] = "The event in requested index is outdated and cleared" +| name | code | strerror | +|-------------------------|------|--------------------------------------------------------| +| EcodeWatcherCleared | 400 | "watcher is cleared due to etcd recovery" | +| EcodeEventIndexCleared | 401 | "The event in requested index is outdated and cleared" | diff --git a/error/error.go b/error/error.go index 7fb18f871..81cbc2c8c 100644 --- a/error/error.go +++ b/error/error.go @@ -14,6 +14,9 @@ limitations under the License. */ +// error package describes errors in etcd project. +// When any change happens, Documentation/errorcode.md needs to be updated +// correspondingly. package error import ( @@ -30,8 +33,8 @@ var errors = map[int]string{ ecodeNoMorePeer: "Reached the max number of peers in the cluster", EcodeNotDir: "Not a directory", EcodeNodeExist: "Key already exists", // create - EcodeRootROnly: "Root is read only", ecodeKeyIsPreserved: "The prefix of given key is a keyword in etcd", + EcodeRootROnly: "Root is read only", EcodeDirNotEmpty: "Directory not empty", ecodeExistingPeerAddr: "Peer address has existed",