Invalid QR Code
This commit is contained in:
parent
7cc4f1d152
commit
961387ab56
@ -66,6 +66,13 @@ func NewError(errType ErrType, message string) *ServiceException {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewErrorMessage(errType *ServiceException, message string) *ServiceException {
|
||||||
|
return &ServiceException{
|
||||||
|
errorType: errType.ErrorType(),
|
||||||
|
message: message,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ServiceException) ErrorType() ErrType {
|
func (s *ServiceException) ErrorType() ErrType {
|
||||||
return s.errorType
|
return s.errorType
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,11 @@ func ErrorWrapper(c *gin.Context, err error) {
|
|||||||
if validErr, ok := err.(errors.Error); ok {
|
if validErr, ok := err.(errors.Error); ok {
|
||||||
status = validErr.MapErrorsToHTTPCode()
|
status = validErr.MapErrorsToHTTPCode()
|
||||||
code = validErr.MapErrorsToCode()
|
code = validErr.MapErrorsToCode()
|
||||||
|
|
||||||
|
if code.GetHTTPCode() != 0 {
|
||||||
|
status = code.GetHTTPCode()
|
||||||
|
}
|
||||||
|
|
||||||
message = code.GetMessage()
|
message = code.GetMessage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -125,6 +125,10 @@ func (s *OrderService) CreateOrder(ctx mycontext.Context, req *entity.OrderReque
|
|||||||
func (s *OrderService) CheckInInquiry(ctx mycontext.Context, qrCode string, partnerID *int64) (*entity.CheckinResponse, error) {
|
func (s *OrderService) CheckInInquiry(ctx mycontext.Context, qrCode string, partnerID *int64) (*entity.CheckinResponse, error) {
|
||||||
order, err := s.repo.FindByQRCode(ctx, qrCode)
|
order, err := s.repo.FindByQRCode(ctx, qrCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
return nil, errors2.NewErrorMessage(errors2.ErrorInvalidRequest, "Not Valid QR Code")
|
||||||
|
}
|
||||||
|
|
||||||
logger.ContextLogger(ctx).Error("error when getting order by QR code", zap.Error(err))
|
logger.ContextLogger(ctx).Error("error when getting order by QR code", zap.Error(err))
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user