Skip to content

Commit 1dd4de0

Browse files
committed
all: consolidate errors
1 parent 1d2ea13 commit 1dd4de0

File tree

3 files changed

+38
-43
lines changed

3 files changed

+38
-43
lines changed

errors.go

+38-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,42 @@
11
package epp
22

3-
import (
4-
"errors"
5-
)
3+
// Error is the interface implemented by all errors in this package.
4+
type Error interface {
5+
eppError()
6+
}
7+
8+
type stringError string
9+
10+
func (stringError) eppError() {}
11+
12+
func (s stringError) Error() string {
13+
return "epp: " + string(s)
14+
}
15+
16+
// ErrClosedConnection indicates a read or write operation on a closed connection.
17+
const ErrClosedConnection stringError = "operation on closed connection"
618

719
// ErrServerClosed indicates a [Server] has shut down or closed.
8-
var ErrServerClosed = errors.New("epp: server closed")
20+
const ErrServerClosed stringError = "server closed"
21+
22+
// TransactionIDError indicates an invalid transaction ID.
23+
type TransactionIDError struct {
24+
TransactionID string
25+
}
26+
27+
func (TransactionIDError) eppError() {}
28+
29+
// Error implements the error interface.
30+
func (err TransactionIDError) Error() string {
31+
return "epp: invalid transaction transaction ID: " + err.TransactionID
32+
}
33+
34+
// DuplicateTransactionIDError indicates a duplicate transaction ID.
35+
type DuplicateTransactionIDError TransactionIDError
36+
37+
func (DuplicateTransactionIDError) eppError() {}
38+
39+
// Error implements the error interface.
40+
func (err DuplicateTransactionIDError) Error() string {
41+
return "epp: duplicate transaction ID: " + err.TransactionID
42+
}

errors/errors.go

-12
This file was deleted.

protocol/errors.go

-27
This file was deleted.

0 commit comments

Comments
 (0)