File: error.go

package info (click to toggle)
golang-github-colinmarc-hdfs 2.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,760 kB
  • sloc: sh: 130; xml: 40; makefile: 31
file content (44 lines) | stat: -rw-r--r-- 907 bytes parent folder | download
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
package rpc

import (
	"fmt"

	hadoop "github.com/colinmarc/hdfs/v2/internal/protocol/hadoop_common"
)

// NamenodeError represents an interepreted error from the Namenode, including
// the error code and the java backtrace. It implements hdfs.Error.
type NamenodeError struct {
	method    string
	code      int
	exception string
	message   string
}

func (err *NamenodeError) Method() string {
	return err.method
}

func (err *NamenodeError) Desc() string {
	return hadoop.RpcResponseHeaderProto_RpcErrorCodeProto_name[int32(err.code)]
}

func (err *NamenodeError) Exception() string {
	return err.exception
}

func (err *NamenodeError) Message() string {
	return err.message
}

func (err *NamenodeError) Error() string {
	s := fmt.Sprintf("%s call failed with %s", err.method, err.Desc())
	if err.exception != "" {
		s += fmt.Sprintf(" (%s)", err.exception)
	}

	return s
}

type DatanodeError struct {
}