Skip to content

Commit

Permalink
feat: panic with error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
r3v4s authored and onlyhyde committed Dec 20, 2024
1 parent cc23954 commit 38ca791
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
25 changes: 13 additions & 12 deletions position/errors.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import (
)

var (
errNoPermission = errors.New("[GNOSWAP-POSITION-001] caller has no permission")
errSlippage = errors.New("[GNOSWAP-POSITION-002] slippage failed")
errWrapUnwrap = errors.New("[GNOSWAP-POSITION-003] wrap, unwrap failed")
errOutOfRange = errors.New("[GNOSWAP-POSITION-004] out of range for numeric value")
errInvalidInput = errors.New("[GNOSWAP-POSITION-005] invalid input data")
errDataNotFound = errors.New("[GNOSWAP-POSITION-006] requested data not found")
errExpired = errors.New("[GNOSWAP-POSITION-007] transaction expired")
errWugnotMinimum = errors.New("[GNOSWAP-POSITION-008] can not wrap less than minimum amount")
errNotClear = errors.New("[GNOSWAP-POSITION-009] position is not clear")
errZeroLiquidity = errors.New("[GNOSWAP-POSITION-010] zero liquidity")
errPositionExist = errors.New("[GNOSWAP-POSITION-011] position with same tokenId already exists")
errInvalidAddress = errors.New("[GNOSWAP-POSITION-012] invalid address")
errNoPermission = errors.New("[GNOSWAP-POSITION-001] caller has no permission")
errSlippage = errors.New("[GNOSWAP-POSITION-002] slippage failed")
errWrapUnwrap = errors.New("[GNOSWAP-POSITION-003] wrap, unwrap failed")
errOutOfRange = errors.New("[GNOSWAP-POSITION-004] out of range for numeric value")
errInvalidInput = errors.New("[GNOSWAP-POSITION-005] invalid input data")
errDataNotFound = errors.New("[GNOSWAP-POSITION-006] requested data not found")
errExpired = errors.New("[GNOSWAP-POSITION-007] transaction expired")
errWugnotMinimum = errors.New("[GNOSWAP-POSITION-008] can not wrap less than minimum amount")
errNotClear = errors.New("[GNOSWAP-POSITION-009] position is not clear")
errZeroLiquidity = errors.New("[GNOSWAP-POSITION-010] zero liquidity")
errPositionExist = errors.New("[GNOSWAP-POSITION-011] position with same tokenId already exists")
errInvalidAddress = errors.New("[GNOSWAP-POSITION-012] invalid address")
errPositionDoesNotExist = errors.New("[GNOSWAP-POSITION-013] position does not exist")
)

func addDetailToError(err error, detail string) string {
Expand Down
6 changes: 4 additions & 2 deletions position/position.gno
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,10 @@ func increaseLiquidity(params IncreaseLiquidityParams) (uint64, *u256.Uint, *u25

updated := setPosition(params.tokenId, position)
if !updated {
// TODO:
panic("position should be updated, not newly created")
panic(addDetailToError(
errPositionDoesNotExist,
ufmt.Sprintf("position(%d) doesn't exist", params.tokenId),
))
}

return params.tokenId, liquidity, amount0, amount1, position.poolKey
Expand Down

0 comments on commit 38ca791

Please sign in to comment.