forked from lightninglabs/lightning-faucet
-
Notifications
You must be signed in to change notification settings - Fork 6
/
errors.go
122 lines (101 loc) · 3.84 KB
/
errors.go
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package main
import (
"fmt"
)
// chanCreationError is an enum which describes the exact nature of an error
// encountered when a user attempts to create a channel with the faucet. This
// enum is used within the templates to determine at which input item the error
// occurred and also to generate an error string unique to the error.
type ChanCreationError uint8
const (
// NoError is the default error which indicates either the form hasn't
// yet been submitted or no errors have arisen.
NoError ChanCreationError = iota
// InvalidAddress indicates that the passed node address is invalid.
InvalidAddress
// NotConnected indicates that the target peer isn't connected to the
// faucet.
NotConnected
// ChanAmountNotNumber indicates that the amount specified for the
// amount to fund the channel with isn't actually a number.
ChanAmountNotNumber
// ChannelTooLarge indicates that the amounts specified to fund the
// channel with is greater than maxChannelSize.
ChannelTooLarge
// ChannelTooSmall indicates that the channel size required is below
// minChannelSize.
ChannelTooSmall
// PushIncorrect indicates that the amount specified to push to the
// other end of the channel is greater-than-or-equal-to the local
// funding amount.
PushIncorrect
// ChannelOpenFail indicates some error occurred when attempting to
// open a channel with the target peer.
ChannelOpenFail
// HaveChannel indicates that the faucet already has a channel open
// with the target node.
HaveChannel
// HavePendingChannel indicates that the faucet already has a channel
// pending with the target node.
HavePendingChannel
// ErrorGeneratingInvoice indicates that some error happened when generating
// an invoice
ErrorGeneratingInvoice
// InvoiceAmountTooHigh indicates the user tried to generate an invoice
// that was too expensive.
InvoiceAmountTooHigh
// ErrorDecodingPayReq indicates the user tried to input wrong invoice to create Payment Request
ErrorDecodingPayReq
// PaymentStreamError indicates that you get an error in the payment stream process
PaymentStreamError
// ErrorPaymentAmount indicates the user tried to pay an invoice with
// a value greater then the limit
ErrorPaymentAmount
// TimeLimitError indicates the user tried to do an action without wait the timelimit
TimeLimitError
// InternalServerError indicates that something has gone wrong on the server
InternalServerError
)
// String returns a human readable string describing the chanCreationError.
// This string is used in the templates in order to display the error to the
// user.
func (c ChanCreationError) String() string {
switch c {
case NoError:
return ""
case InvalidAddress:
return "Not a valid public key"
case NotConnected:
return "Faucet cannot connect to this node"
case ChanAmountNotNumber:
return "Amount must be a number"
case ChannelTooLarge:
return "Amount is too large"
case ChannelTooSmall:
return fmt.Sprintf("Minimum channel size is is %d DCR", minChannelSize)
case PushIncorrect:
return "Initial Balance is incorrect"
case ChannelOpenFail:
return "Faucet is not able to open a channel with this node"
case HaveChannel:
return "Faucet already has an active channel with this node"
case HavePendingChannel:
return "Faucet already has a pending channel with this node"
case ErrorGeneratingInvoice:
return "Error generating Invoice"
case InvoiceAmountTooHigh:
return "Invoice amount too high"
case ErrorDecodingPayReq:
return "Error decoding payment request"
case PaymentStreamError:
return "Error on payment request, try again"
case ErrorPaymentAmount:
return fmt.Sprintf("The amount of invoice exceeds the limit of %d Atoms", maxPaymentAtoms)
case TimeLimitError:
return "Action time limited. Please wait."
case InternalServerError:
return "An internal error has occurred."
default:
return fmt.Sprintf("%v", uint8(c))
}
}