go.uber.org/yarpc@v1.72.1/encoding/thrift/internal/internal.go (about)

     1  // Code generated by thriftrw v1.29.2. DO NOT EDIT.
     2  // @generated
     3  
     4  // Copyright (c) 2022 Uber Technologies, Inc.
     5  //
     6  // Permission is hereby granted, free of charge, to any person obtaining a copy
     7  // of this software and associated documentation files (the "Software"), to deal
     8  // in the Software without restriction, including without limitation the rights
     9  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    10  // copies of the Software, and to permit persons to whom the Software is
    11  // furnished to do so, subject to the following conditions:
    12  //
    13  // The above copyright notice and this permission notice shall be included in
    14  // all copies or substantial portions of the Software.
    15  //
    16  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    17  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    18  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    19  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    20  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    21  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    22  // THE SOFTWARE.
    23  
    24  package internal
    25  
    26  import (
    27  	bytes "bytes"
    28  	json "encoding/json"
    29  	fmt "fmt"
    30  	multierr "go.uber.org/multierr"
    31  	stream "go.uber.org/thriftrw/protocol/stream"
    32  	thriftreflect "go.uber.org/thriftrw/thriftreflect"
    33  	wire "go.uber.org/thriftrw/wire"
    34  	zapcore "go.uber.org/zap/zapcore"
    35  	math "math"
    36  	strconv "strconv"
    37  	strings "strings"
    38  )
    39  
    40  type ExceptionType int32
    41  
    42  const (
    43  	ExceptionTypeUnknown               ExceptionType = 0
    44  	ExceptionTypeUnknownMethod         ExceptionType = 1
    45  	ExceptionTypeInvalidMessageType    ExceptionType = 2
    46  	ExceptionTypeWrongMethodName       ExceptionType = 3
    47  	ExceptionTypeBadSequenceID         ExceptionType = 4
    48  	ExceptionTypeMissingResult         ExceptionType = 5
    49  	ExceptionTypeInternalError         ExceptionType = 6
    50  	ExceptionTypeProtocolError         ExceptionType = 7
    51  	ExceptionTypeInvalidTransform      ExceptionType = 8
    52  	ExceptionTypeInvalidProtocol       ExceptionType = 9
    53  	ExceptionTypeUnsupportedClientType ExceptionType = 10
    54  )
    55  
    56  // ExceptionType_Values returns all recognized values of ExceptionType.
    57  func ExceptionType_Values() []ExceptionType {
    58  	return []ExceptionType{
    59  		ExceptionTypeUnknown,
    60  		ExceptionTypeUnknownMethod,
    61  		ExceptionTypeInvalidMessageType,
    62  		ExceptionTypeWrongMethodName,
    63  		ExceptionTypeBadSequenceID,
    64  		ExceptionTypeMissingResult,
    65  		ExceptionTypeInternalError,
    66  		ExceptionTypeProtocolError,
    67  		ExceptionTypeInvalidTransform,
    68  		ExceptionTypeInvalidProtocol,
    69  		ExceptionTypeUnsupportedClientType,
    70  	}
    71  }
    72  
    73  // UnmarshalText tries to decode ExceptionType from a byte slice
    74  // containing its name.
    75  //
    76  //   var v ExceptionType
    77  //   err := v.UnmarshalText([]byte("UNKNOWN"))
    78  func (v *ExceptionType) UnmarshalText(value []byte) error {
    79  	switch s := string(value); s {
    80  	case "UNKNOWN":
    81  		*v = ExceptionTypeUnknown
    82  		return nil
    83  	case "UNKNOWN_METHOD":
    84  		*v = ExceptionTypeUnknownMethod
    85  		return nil
    86  	case "INVALID_MESSAGE_TYPE":
    87  		*v = ExceptionTypeInvalidMessageType
    88  		return nil
    89  	case "WRONG_METHOD_NAME":
    90  		*v = ExceptionTypeWrongMethodName
    91  		return nil
    92  	case "BAD_SEQUENCE_ID":
    93  		*v = ExceptionTypeBadSequenceID
    94  		return nil
    95  	case "MISSING_RESULT":
    96  		*v = ExceptionTypeMissingResult
    97  		return nil
    98  	case "INTERNAL_ERROR":
    99  		*v = ExceptionTypeInternalError
   100  		return nil
   101  	case "PROTOCOL_ERROR":
   102  		*v = ExceptionTypeProtocolError
   103  		return nil
   104  	case "INVALID_TRANSFORM":
   105  		*v = ExceptionTypeInvalidTransform
   106  		return nil
   107  	case "INVALID_PROTOCOL":
   108  		*v = ExceptionTypeInvalidProtocol
   109  		return nil
   110  	case "UNSUPPORTED_CLIENT_TYPE":
   111  		*v = ExceptionTypeUnsupportedClientType
   112  		return nil
   113  	default:
   114  		val, err := strconv.ParseInt(s, 10, 32)
   115  		if err != nil {
   116  			return fmt.Errorf("unknown enum value %q for %q: %v", s, "ExceptionType", err)
   117  		}
   118  		*v = ExceptionType(val)
   119  		return nil
   120  	}
   121  }
   122  
   123  // MarshalText encodes ExceptionType to text.
   124  //
   125  // If the enum value is recognized, its name is returned.
   126  // Otherwise, its integer value is returned.
   127  //
   128  // This implements the TextMarshaler interface.
   129  func (v ExceptionType) MarshalText() ([]byte, error) {
   130  	switch int32(v) {
   131  	case 0:
   132  		return []byte("UNKNOWN"), nil
   133  	case 1:
   134  		return []byte("UNKNOWN_METHOD"), nil
   135  	case 2:
   136  		return []byte("INVALID_MESSAGE_TYPE"), nil
   137  	case 3:
   138  		return []byte("WRONG_METHOD_NAME"), nil
   139  	case 4:
   140  		return []byte("BAD_SEQUENCE_ID"), nil
   141  	case 5:
   142  		return []byte("MISSING_RESULT"), nil
   143  	case 6:
   144  		return []byte("INTERNAL_ERROR"), nil
   145  	case 7:
   146  		return []byte("PROTOCOL_ERROR"), nil
   147  	case 8:
   148  		return []byte("INVALID_TRANSFORM"), nil
   149  	case 9:
   150  		return []byte("INVALID_PROTOCOL"), nil
   151  	case 10:
   152  		return []byte("UNSUPPORTED_CLIENT_TYPE"), nil
   153  	}
   154  	return []byte(strconv.FormatInt(int64(v), 10)), nil
   155  }
   156  
   157  // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
   158  // fast logging of ExceptionType.
   159  // Enums are logged as objects, where the value is logged with key "value", and
   160  // if this value's name is known, the name is logged with key "name".
   161  func (v ExceptionType) MarshalLogObject(enc zapcore.ObjectEncoder) error {
   162  	enc.AddInt32("value", int32(v))
   163  	switch int32(v) {
   164  	case 0:
   165  		enc.AddString("name", "UNKNOWN")
   166  	case 1:
   167  		enc.AddString("name", "UNKNOWN_METHOD")
   168  	case 2:
   169  		enc.AddString("name", "INVALID_MESSAGE_TYPE")
   170  	case 3:
   171  		enc.AddString("name", "WRONG_METHOD_NAME")
   172  	case 4:
   173  		enc.AddString("name", "BAD_SEQUENCE_ID")
   174  	case 5:
   175  		enc.AddString("name", "MISSING_RESULT")
   176  	case 6:
   177  		enc.AddString("name", "INTERNAL_ERROR")
   178  	case 7:
   179  		enc.AddString("name", "PROTOCOL_ERROR")
   180  	case 8:
   181  		enc.AddString("name", "INVALID_TRANSFORM")
   182  	case 9:
   183  		enc.AddString("name", "INVALID_PROTOCOL")
   184  	case 10:
   185  		enc.AddString("name", "UNSUPPORTED_CLIENT_TYPE")
   186  	}
   187  	return nil
   188  }
   189  
   190  // Ptr returns a pointer to this enum value.
   191  func (v ExceptionType) Ptr() *ExceptionType {
   192  	return &v
   193  }
   194  
   195  // Encode encodes ExceptionType directly to bytes.
   196  //
   197  //   sWriter := BinaryStreamer.Writer(writer)
   198  //
   199  //   var v ExceptionType
   200  //   return v.Encode(sWriter)
   201  func (v ExceptionType) Encode(sw stream.Writer) error {
   202  	return sw.WriteInt32(int32(v))
   203  }
   204  
   205  // ToWire translates ExceptionType into a Thrift-level intermediate
   206  // representation. This intermediate representation may be serialized
   207  // into bytes using a ThriftRW protocol implementation.
   208  //
   209  // Enums are represented as 32-bit integers over the wire.
   210  func (v ExceptionType) ToWire() (wire.Value, error) {
   211  	return wire.NewValueI32(int32(v)), nil
   212  }
   213  
   214  // FromWire deserializes ExceptionType from its Thrift-level
   215  // representation.
   216  //
   217  //   x, err := binaryProtocol.Decode(reader, wire.TI32)
   218  //   if err != nil {
   219  //     return ExceptionType(0), err
   220  //   }
   221  //
   222  //   var v ExceptionType
   223  //   if err := v.FromWire(x); err != nil {
   224  //     return ExceptionType(0), err
   225  //   }
   226  //   return v, nil
   227  func (v *ExceptionType) FromWire(w wire.Value) error {
   228  	*v = (ExceptionType)(w.GetI32())
   229  	return nil
   230  }
   231  
   232  // Decode reads off the encoded ExceptionType directly off of the wire.
   233  //
   234  //   sReader := BinaryStreamer.Reader(reader)
   235  //
   236  //   var v ExceptionType
   237  //   if err := v.Decode(sReader); err != nil {
   238  //     return ExceptionType(0), err
   239  //   }
   240  //   return v, nil
   241  func (v *ExceptionType) Decode(sr stream.Reader) error {
   242  	i, err := sr.ReadInt32()
   243  	if err != nil {
   244  		return err
   245  	}
   246  	*v = (ExceptionType)(i)
   247  	return nil
   248  }
   249  
   250  // String returns a readable string representation of ExceptionType.
   251  func (v ExceptionType) String() string {
   252  	w := int32(v)
   253  	switch w {
   254  	case 0:
   255  		return "UNKNOWN"
   256  	case 1:
   257  		return "UNKNOWN_METHOD"
   258  	case 2:
   259  		return "INVALID_MESSAGE_TYPE"
   260  	case 3:
   261  		return "WRONG_METHOD_NAME"
   262  	case 4:
   263  		return "BAD_SEQUENCE_ID"
   264  	case 5:
   265  		return "MISSING_RESULT"
   266  	case 6:
   267  		return "INTERNAL_ERROR"
   268  	case 7:
   269  		return "PROTOCOL_ERROR"
   270  	case 8:
   271  		return "INVALID_TRANSFORM"
   272  	case 9:
   273  		return "INVALID_PROTOCOL"
   274  	case 10:
   275  		return "UNSUPPORTED_CLIENT_TYPE"
   276  	}
   277  	return fmt.Sprintf("ExceptionType(%d)", w)
   278  }
   279  
   280  // Equals returns true if this ExceptionType value matches the provided
   281  // value.
   282  func (v ExceptionType) Equals(rhs ExceptionType) bool {
   283  	return v == rhs
   284  }
   285  
   286  // MarshalJSON serializes ExceptionType into JSON.
   287  //
   288  // If the enum value is recognized, its name is returned.
   289  // Otherwise, its integer value is returned.
   290  //
   291  // This implements json.Marshaler.
   292  func (v ExceptionType) MarshalJSON() ([]byte, error) {
   293  	switch int32(v) {
   294  	case 0:
   295  		return ([]byte)("\"UNKNOWN\""), nil
   296  	case 1:
   297  		return ([]byte)("\"UNKNOWN_METHOD\""), nil
   298  	case 2:
   299  		return ([]byte)("\"INVALID_MESSAGE_TYPE\""), nil
   300  	case 3:
   301  		return ([]byte)("\"WRONG_METHOD_NAME\""), nil
   302  	case 4:
   303  		return ([]byte)("\"BAD_SEQUENCE_ID\""), nil
   304  	case 5:
   305  		return ([]byte)("\"MISSING_RESULT\""), nil
   306  	case 6:
   307  		return ([]byte)("\"INTERNAL_ERROR\""), nil
   308  	case 7:
   309  		return ([]byte)("\"PROTOCOL_ERROR\""), nil
   310  	case 8:
   311  		return ([]byte)("\"INVALID_TRANSFORM\""), nil
   312  	case 9:
   313  		return ([]byte)("\"INVALID_PROTOCOL\""), nil
   314  	case 10:
   315  		return ([]byte)("\"UNSUPPORTED_CLIENT_TYPE\""), nil
   316  	}
   317  	return ([]byte)(strconv.FormatInt(int64(v), 10)), nil
   318  }
   319  
   320  // UnmarshalJSON attempts to decode ExceptionType from its JSON
   321  // representation.
   322  //
   323  // This implementation supports both, numeric and string inputs. If a
   324  // string is provided, it must be a known enum name.
   325  //
   326  // This implements json.Unmarshaler.
   327  func (v *ExceptionType) UnmarshalJSON(text []byte) error {
   328  	d := json.NewDecoder(bytes.NewReader(text))
   329  	d.UseNumber()
   330  	t, err := d.Token()
   331  	if err != nil {
   332  		return err
   333  	}
   334  
   335  	switch w := t.(type) {
   336  	case json.Number:
   337  		x, err := w.Int64()
   338  		if err != nil {
   339  			return err
   340  		}
   341  		if x > math.MaxInt32 {
   342  			return fmt.Errorf("enum overflow from JSON %q for %q", text, "ExceptionType")
   343  		}
   344  		if x < math.MinInt32 {
   345  			return fmt.Errorf("enum underflow from JSON %q for %q", text, "ExceptionType")
   346  		}
   347  		*v = (ExceptionType)(x)
   348  		return nil
   349  	case string:
   350  		return v.UnmarshalText([]byte(w))
   351  	default:
   352  		return fmt.Errorf("invalid JSON value %q (%T) to unmarshal into %q", t, t, "ExceptionType")
   353  	}
   354  }
   355  
   356  // TApplicationException is a Thrift-level exception.
   357  //
   358  // Thrift envelopes with the type Exception contain an exception of this
   359  // shape.
   360  type TApplicationException struct {
   361  	Message *string        `json:"message,omitempty"`
   362  	Type    *ExceptionType `json:"type,omitempty"`
   363  }
   364  
   365  // ToWire translates a TApplicationException struct into a Thrift-level intermediate
   366  // representation. This intermediate representation may be serialized
   367  // into bytes using a ThriftRW protocol implementation.
   368  //
   369  // An error is returned if the struct or any of its fields failed to
   370  // validate.
   371  //
   372  //   x, err := v.ToWire()
   373  //   if err != nil {
   374  //     return err
   375  //   }
   376  //
   377  //   if err := binaryProtocol.Encode(x, writer); err != nil {
   378  //     return err
   379  //   }
   380  func (v *TApplicationException) ToWire() (wire.Value, error) {
   381  	var (
   382  		fields [2]wire.Field
   383  		i      int = 0
   384  		w      wire.Value
   385  		err    error
   386  	)
   387  
   388  	if v.Message != nil {
   389  		w, err = wire.NewValueString(*(v.Message)), error(nil)
   390  		if err != nil {
   391  			return w, err
   392  		}
   393  		fields[i] = wire.Field{ID: 1, Value: w}
   394  		i++
   395  	}
   396  	if v.Type != nil {
   397  		w, err = v.Type.ToWire()
   398  		if err != nil {
   399  			return w, err
   400  		}
   401  		fields[i] = wire.Field{ID: 2, Value: w}
   402  		i++
   403  	}
   404  
   405  	return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
   406  }
   407  
   408  func _ExceptionType_Read(w wire.Value) (ExceptionType, error) {
   409  	var v ExceptionType
   410  	err := v.FromWire(w)
   411  	return v, err
   412  }
   413  
   414  // FromWire deserializes a TApplicationException struct from its Thrift-level
   415  // representation. The Thrift-level representation may be obtained
   416  // from a ThriftRW protocol implementation.
   417  //
   418  // An error is returned if we were unable to build a TApplicationException struct
   419  // from the provided intermediate representation.
   420  //
   421  //   x, err := binaryProtocol.Decode(reader, wire.TStruct)
   422  //   if err != nil {
   423  //     return nil, err
   424  //   }
   425  //
   426  //   var v TApplicationException
   427  //   if err := v.FromWire(x); err != nil {
   428  //     return nil, err
   429  //   }
   430  //   return &v, nil
   431  func (v *TApplicationException) FromWire(w wire.Value) error {
   432  	var err error
   433  
   434  	for _, field := range w.GetStruct().Fields {
   435  		switch field.ID {
   436  		case 1:
   437  			if field.Value.Type() == wire.TBinary {
   438  				var x string
   439  				x, err = field.Value.GetString(), error(nil)
   440  				v.Message = &x
   441  				if err != nil {
   442  					return err
   443  				}
   444  
   445  			}
   446  		case 2:
   447  			if field.Value.Type() == wire.TI32 {
   448  				var x ExceptionType
   449  				x, err = _ExceptionType_Read(field.Value)
   450  				v.Type = &x
   451  				if err != nil {
   452  					return err
   453  				}
   454  
   455  			}
   456  		}
   457  	}
   458  
   459  	return nil
   460  }
   461  
   462  // Encode serializes a TApplicationException struct directly into bytes, without going
   463  // through an intermediary type.
   464  //
   465  // An error is returned if a TApplicationException struct could not be encoded.
   466  func (v *TApplicationException) Encode(sw stream.Writer) error {
   467  	if err := sw.WriteStructBegin(); err != nil {
   468  		return err
   469  	}
   470  
   471  	if v.Message != nil {
   472  		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 1, Type: wire.TBinary}); err != nil {
   473  			return err
   474  		}
   475  		if err := sw.WriteString(*(v.Message)); err != nil {
   476  			return err
   477  		}
   478  		if err := sw.WriteFieldEnd(); err != nil {
   479  			return err
   480  		}
   481  	}
   482  
   483  	if v.Type != nil {
   484  		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 2, Type: wire.TI32}); err != nil {
   485  			return err
   486  		}
   487  		if err := v.Type.Encode(sw); err != nil {
   488  			return err
   489  		}
   490  		if err := sw.WriteFieldEnd(); err != nil {
   491  			return err
   492  		}
   493  	}
   494  
   495  	return sw.WriteStructEnd()
   496  }
   497  
   498  func _ExceptionType_Decode(sr stream.Reader) (ExceptionType, error) {
   499  	var v ExceptionType
   500  	err := v.Decode(sr)
   501  	return v, err
   502  }
   503  
   504  // Decode deserializes a TApplicationException struct directly from its Thrift-level
   505  // representation, without going through an intemediary type.
   506  //
   507  // An error is returned if a TApplicationException struct could not be generated from the wire
   508  // representation.
   509  func (v *TApplicationException) Decode(sr stream.Reader) error {
   510  
   511  	if err := sr.ReadStructBegin(); err != nil {
   512  		return err
   513  	}
   514  
   515  	fh, ok, err := sr.ReadFieldBegin()
   516  	if err != nil {
   517  		return err
   518  	}
   519  
   520  	for ok {
   521  		switch {
   522  		case fh.ID == 1 && fh.Type == wire.TBinary:
   523  			var x string
   524  			x, err = sr.ReadString()
   525  			v.Message = &x
   526  			if err != nil {
   527  				return err
   528  			}
   529  
   530  		case fh.ID == 2 && fh.Type == wire.TI32:
   531  			var x ExceptionType
   532  			x, err = _ExceptionType_Decode(sr)
   533  			v.Type = &x
   534  			if err != nil {
   535  				return err
   536  			}
   537  
   538  		default:
   539  			if err := sr.Skip(fh.Type); err != nil {
   540  				return err
   541  			}
   542  		}
   543  
   544  		if err := sr.ReadFieldEnd(); err != nil {
   545  			return err
   546  		}
   547  
   548  		if fh, ok, err = sr.ReadFieldBegin(); err != nil {
   549  			return err
   550  		}
   551  	}
   552  
   553  	if err := sr.ReadStructEnd(); err != nil {
   554  		return err
   555  	}
   556  
   557  	return nil
   558  }
   559  
   560  // String returns a readable string representation of a TApplicationException
   561  // struct.
   562  func (v *TApplicationException) String() string {
   563  	if v == nil {
   564  		return "<nil>"
   565  	}
   566  
   567  	var fields [2]string
   568  	i := 0
   569  	if v.Message != nil {
   570  		fields[i] = fmt.Sprintf("Message: %v", *(v.Message))
   571  		i++
   572  	}
   573  	if v.Type != nil {
   574  		fields[i] = fmt.Sprintf("Type: %v", *(v.Type))
   575  		i++
   576  	}
   577  
   578  	return fmt.Sprintf("TApplicationException{%v}", strings.Join(fields[:i], ", "))
   579  }
   580  
   581  // ErrorName is the name of this type as defined in the Thrift
   582  // file.
   583  func (*TApplicationException) ErrorName() string {
   584  	return "TApplicationException"
   585  }
   586  
   587  func _String_EqualsPtr(lhs, rhs *string) bool {
   588  	if lhs != nil && rhs != nil {
   589  
   590  		x := *lhs
   591  		y := *rhs
   592  		return (x == y)
   593  	}
   594  	return lhs == nil && rhs == nil
   595  }
   596  
   597  func _ExceptionType_EqualsPtr(lhs, rhs *ExceptionType) bool {
   598  	if lhs != nil && rhs != nil {
   599  
   600  		x := *lhs
   601  		y := *rhs
   602  		return x.Equals(y)
   603  	}
   604  	return lhs == nil && rhs == nil
   605  }
   606  
   607  // Equals returns true if all the fields of this TApplicationException match the
   608  // provided TApplicationException.
   609  //
   610  // This function performs a deep comparison.
   611  func (v *TApplicationException) Equals(rhs *TApplicationException) bool {
   612  	if v == nil {
   613  		return rhs == nil
   614  	} else if rhs == nil {
   615  		return false
   616  	}
   617  	if !_String_EqualsPtr(v.Message, rhs.Message) {
   618  		return false
   619  	}
   620  	if !_ExceptionType_EqualsPtr(v.Type, rhs.Type) {
   621  		return false
   622  	}
   623  
   624  	return true
   625  }
   626  
   627  // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
   628  // fast logging of TApplicationException.
   629  func (v *TApplicationException) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
   630  	if v == nil {
   631  		return nil
   632  	}
   633  	if v.Message != nil {
   634  		enc.AddString("message", *v.Message)
   635  	}
   636  	if v.Type != nil {
   637  		err = multierr.Append(err, enc.AddObject("type", *v.Type))
   638  	}
   639  	return err
   640  }
   641  
   642  // GetMessage returns the value of Message if it is set or its
   643  // zero value if it is unset.
   644  func (v *TApplicationException) GetMessage() (o string) {
   645  	if v != nil && v.Message != nil {
   646  		return *v.Message
   647  	}
   648  
   649  	return
   650  }
   651  
   652  // IsSetMessage returns true if Message is not nil.
   653  func (v *TApplicationException) IsSetMessage() bool {
   654  	return v != nil && v.Message != nil
   655  }
   656  
   657  // GetType returns the value of Type if it is set or its
   658  // zero value if it is unset.
   659  func (v *TApplicationException) GetType() (o ExceptionType) {
   660  	if v != nil && v.Type != nil {
   661  		return *v.Type
   662  	}
   663  
   664  	return
   665  }
   666  
   667  // IsSetType returns true if Type is not nil.
   668  func (v *TApplicationException) IsSetType() bool {
   669  	return v != nil && v.Type != nil
   670  }
   671  
   672  func (v *TApplicationException) Error() string {
   673  	return v.String()
   674  }
   675  
   676  // ThriftModule represents the IDL file used to generate this package.
   677  var ThriftModule = &thriftreflect.ThriftModule{
   678  	Name:     "internal",
   679  	Package:  "go.uber.org/yarpc/encoding/thrift/internal",
   680  	FilePath: "internal.thrift",
   681  	SHA1:     "43d339d0566531c13482a795ecce0eb36785cbff",
   682  	Raw:      rawIDL,
   683  }
   684  
   685  const rawIDL = "enum ExceptionType {\n  UNKNOWN = 0\n  UNKNOWN_METHOD = 1\n  INVALID_MESSAGE_TYPE = 2\n  WRONG_METHOD_NAME = 3\n  BAD_SEQUENCE_ID = 4\n  MISSING_RESULT = 5\n  INTERNAL_ERROR = 6\n  PROTOCOL_ERROR = 7\n  INVALID_TRANSFORM = 8\n  INVALID_PROTOCOL = 9\n  UNSUPPORTED_CLIENT_TYPE = 10\n}\n\n/**\n * TApplicationException is a Thrift-level exception.\n *\n * Thrift envelopes with the type Exception contain an exception of this\n * shape.\n */\nexception TApplicationException {\n  1: optional string message\n  2: optional ExceptionType type\n}\n"