storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/pkg/rpc/json2/error.go (about) 1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Copyright 2012 The Gorilla Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 // Copyright 2020 MinIO, Inc. All rights reserved. 7 // forked from https://github.com/gorilla/rpc/v2 8 // modified to be used with MinIO under Apache 9 // 2.0 license that can be found in the LICENSE file. 10 11 package json2 12 13 import ( 14 "errors" 15 ) 16 17 type ErrorCode int 18 19 const ( 20 E_PARSE ErrorCode = -32700 21 E_INVALID_REQ ErrorCode = -32600 22 E_NO_METHOD ErrorCode = -32601 23 E_BAD_PARAMS ErrorCode = -32602 24 E_INTERNAL ErrorCode = -32603 25 E_SERVER ErrorCode = -32000 26 ) 27 28 var ErrNullResult = errors.New("result is null") 29 30 type Error struct { 31 // A Number that indicates the error type that occurred. 32 Code ErrorCode `json:"code"` /* required */ 33 34 // A String providing a short description of the error. 35 // The message SHOULD be limited to a concise single sentence. 36 Message string `json:"message"` /* required */ 37 38 // A Primitive or Structured value that contains additional information about the error. 39 Data interface{} `json:"data"` /* optional */ 40 } 41 42 func (e *Error) Error() string { 43 return e.Message 44 }