Replicate old error handling in /v2/exchange_rates.
This commit is contained in:
parent
a280a37ae7
commit
2ed2094d1c
|
@ -219,9 +219,10 @@ func addV2API(router *httprouter.Router, db lurkcoin.Database,
|
|||
|
||||
v2Post(router, db, "exchange_rates", false,
|
||||
func(r *HTTPRequest, f v2Form) (interface{}, error) {
|
||||
// Invalid amounts are assumed to be 1.
|
||||
amount, err := lurkcoin.ParseCurrency(f.Get("amount"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if err != nil || !amount.GtZero() {
|
||||
amount = c1
|
||||
}
|
||||
|
||||
return lurkcoin.GetExchangeRate(r.Database, f.Get("from"),
|
||||
|
@ -233,8 +234,8 @@ func addV2API(router *httprouter.Router, db lurkcoin.Database,
|
|||
v2Post(router, db, "get_exchange_rate", false,
|
||||
func(r *HTTPRequest, f v2Form) (interface{}, error) {
|
||||
amount, err := lurkcoin.ParseCurrency(f.Get("amount"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if err != nil || !amount.GtZero() {
|
||||
amount = c1
|
||||
}
|
||||
|
||||
return lurkcoin.GetExchangeRate(r.Database, f.Get("name"),
|
||||
|
|
Loading…
Reference in New Issue