Skip to content

Commit

Permalink
backend/refactor/added_errors_driver_fee
Browse files Browse the repository at this point in the history
  • Loading branch information
Utkarsh Pandey1 authored and hkmangla committed Jun 27, 2023
1 parent 7845613 commit aadcf1d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/mobility-core/src/Kernel/Types/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ data AuthPIError = NotAnExecutor deriving (Eq, Show, IsBecknAPIError)
instanceExceptionWithParent 'HTTPException ''AuthPIError

instance IsBaseError AuthPIError where
toMessage NotAnExecutor = Just "You are not an executor of this ride."
toMessage NotAnExecutor = Just "You are not an executor of this operation."

instance IsHTTPError AuthPIError where
toErrorCode NotAnExecutor = "NOT_AN_EXECUTOR"
Expand Down Expand Up @@ -990,6 +990,7 @@ instance IsAPIError PaymentOrderError
data DriverFeeError
= DriverFeeNotFound Text
| DriverFeeAlreadySettled Text
| DriverFeeNotInUse Text
deriving (Eq, Show, IsBecknAPIError)

instanceExceptionWithParent 'HTTPException ''DriverFeeError
Expand All @@ -998,14 +999,17 @@ instance IsBaseError DriverFeeError where
toMessage = \case
DriverFeeNotFound driverFeeId -> Just $ "DriverFee with id \"" <> show driverFeeId <> "\"not found. "
DriverFeeAlreadySettled driverFeeId -> Just $ "DriverFee with id \"" <> show driverFeeId <> "\"is already settled."
DriverFeeNotInUse driverFeeId -> Just $ "DriverFee with id \"" <> show driverFeeId <> "\"is either Ongoing or Inactive."

instance IsHTTPError DriverFeeError where
toErrorCode = \case
DriverFeeNotFound _ -> "DRIVER_FEE_NOT_FOUND"
DriverFeeAlreadySettled _ -> "DRIVER_FEE_ALREDAY_SETTLED"
DriverFeeNotInUse _ -> "DRIVER_FEE_NOT_ACTIVE"

toHttpCode = \case
DriverFeeNotFound _ -> E500
DriverFeeAlreadySettled _ -> E400
DriverFeeNotInUse _ -> E400

instance IsAPIError DriverFeeError

0 comments on commit aadcf1d

Please sign in to comment.