Debian Codegraph @

internal/rpc/error.go

raw
1 package rpc
2
3 import (
4 "fmt"
5
6 hadoop "github.com/colinmarc/hdfs/v2/internal/protocol/hadoop_common"
7 )
8
9 // NamenodeError represents an interepreted error from the Namenode, including
10 // the error code and the java backtrace. It implements hdfs.Error.
11 type NamenodeError struct {
12 method string
13 code int
14 exception string
15 message string
16 }
17
18 func (err *NamenodeError) Method() string {
19 return err.method
20 }
21
22 func (err *NamenodeError) Desc() string {
23 return hadoop.RpcResponseHeaderProto_RpcErrorCodeProto_name[int32(err.code)]
24 }
25
26 func (err *NamenodeError) Exception() string {
27 return err.exception
28 }
29
30 func (err *NamenodeError) Message() string {
31 return err.message
32 }
33
34 func (err *NamenodeError) Error() string {
35 s := fmt.Sprintf("%s call failed with %s", err.method, err.Desc())
36 if err.exception != "" {
37 s += fmt.Sprintf(" (%s)", err.exception)
38 }
39
40 return s
41 }
42
43 type DatanodeError struct {
44 }