mirror of
https://github.com/luxfi/api.git
synced 2026-09-24 00:24:53 +00:00
zap: an error the wire has no word for must not read as success
ErrorUnspecified is the zero value and carries "the call succeeded" — a reply holding it is read as a good answer and its fields are trusted. The only other codes name a closed database and a missing key, so every other failure had nowhere to go and was reported as the zero. A caller then took a zero-valued block as a real one. ErrorInternal gives those failures a word. Appending is safe in both directions: errorFromZAP's default arm turns an unknown code into an error, so a reader that predates this still sees a failure rather than a success. Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
@@ -20,11 +20,17 @@ const (
|
||||
// Error represents VM errors
|
||||
type Error uint8
|
||||
|
||||
// The zero value carries "the call succeeded" — a reply whose Err is
|
||||
// ErrorUnspecified is read as a good answer and its fields are trusted. Every
|
||||
// other value names a failure, so a failure the vocabulary has no word for
|
||||
// must reach the caller as ErrorInternal. Mapping it onto the zero instead
|
||||
// hands back a zero-valued block under the name of success.
|
||||
const (
|
||||
ErrorUnspecified Error = iota
|
||||
ErrorClosed
|
||||
ErrorNotFound
|
||||
ErrorStateSyncNotImplemented
|
||||
ErrorInternal
|
||||
)
|
||||
|
||||
// InitializeRequest contains initialization parameters.
|
||||
|
||||
Reference in New Issue
Block a user