/
framer.vdl.go
122 lines (102 loc) · 3.71 KB
/
framer.vdl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file was auto-generated by the vanadium vdl tool.
// Package: framer
//nolint:golint
package framer
import (
"fmt"
"v.io/v23/context"
"v.io/v23/i18n"
"v.io/v23/verror"
)
var _ = initializeVDL() // Must be first; see initializeVDL comments for details.
// Error definitions
// =================
var (
ErrLargerThan3ByteUInt = verror.NewIDAction("v.io/x/ref/runtime/protocols/lib/framer.LargerThan3ByteUInt", verror.NoRetry)
)
// NewErrLargerThan3ByteUInt returns an error with the ErrLargerThan3ByteUInt ID.
// Deprecated: this function will be removed in the future,
// use ErrorfLargerThan3ByteUInt or MessageLargerThan3ByteUInt instead.
func NewErrLargerThan3ByteUInt(ctx *context.T) error {
return verror.New(ErrLargerThan3ByteUInt, ctx)
}
// ErrorfLargerThan3ByteUInt calls ErrLargerThan3ByteUInt.Errorf with the supplied arguments.
func ErrorfLargerThan3ByteUInt(ctx *context.T, format string) error {
return ErrLargerThan3ByteUInt.Errorf(ctx, format)
}
// MessageLargerThan3ByteUInt calls ErrLargerThan3ByteUInt.Message with the supplied arguments.
func MessageLargerThan3ByteUInt(ctx *context.T, message string) error {
return ErrLargerThan3ByteUInt.Message(ctx, message)
}
// ParamsErrLargerThan3ByteUInt extracts the expected parameters from the error's ParameterList.
func ParamsErrLargerThan3ByteUInt(argumentError error) (verrorComponent string, verrorOperation string, returnErr error) {
params := verror.Params(argumentError)
if params == nil {
returnErr = fmt.Errorf("no parameters found in: %T: %v", argumentError, argumentError)
return
}
iter := ¶mListIterator{params: params, max: len(params)}
if verrorComponent, verrorOperation, returnErr = iter.preamble(); returnErr != nil {
return
}
return
}
type paramListIterator struct {
err error
idx, max int
params []interface{}
}
func (pl *paramListIterator) next() (interface{}, error) {
if pl.err != nil {
return nil, pl.err
}
if pl.idx+1 > pl.max {
pl.err = fmt.Errorf("too few parameters: have %v", pl.max)
return nil, pl.err
}
pl.idx++
return pl.params[pl.idx-1], nil
}
func (pl *paramListIterator) preamble() (component, operation string, err error) {
var tmp interface{}
if tmp, err = pl.next(); err != nil {
return
}
var ok bool
if component, ok = tmp.(string); !ok {
return "", "", fmt.Errorf("ParamList[0]: component name is not a string: %T", tmp)
}
if tmp, err = pl.next(); err != nil {
return
}
if operation, ok = tmp.(string); !ok {
return "", "", fmt.Errorf("ParamList[1]: operation name is not a string: %T", tmp)
}
return
}
var initializeVDLCalled bool
// initializeVDL performs vdl initialization. It is safe to call multiple times.
// If you have an init ordering issue, just insert the following line verbatim
// into your source files in this package, right after the "package foo" clause:
//
// var _ = initializeVDL()
//
// The purpose of this function is to ensure that vdl initialization occurs in
// the right order, and very early in the init sequence. In particular, vdl
// registration and package variable initialization needs to occur before
// functions like vdl.TypeOf will work properly.
//
// This function returns a dummy value, so that it can be used to initialize the
// first var in the file, to take advantage of Go's defined init order.
func initializeVDL() struct{} {
if initializeVDLCalled {
return struct{}{}
}
initializeVDLCalled = true
// Set error format strings.
i18n.Cat().SetWithBase(i18n.LangID("en"), i18n.MsgID(ErrLargerThan3ByteUInt.ID), "{1:}{2:} integer too large to represent in 3 bytes")
return struct{}{}
}