@@ -233,7 +233,7 @@ def check_validation(value: str) -> bool:
233233 return False
234234
235235
236- def validate_mobile (mobile : str ) -> bool :
236+ def is_mobile_valid (mobile : str ) -> bool :
237237 """
238238 This function checks if the mobile number is valid or not.
239239 Parameters
@@ -248,12 +248,12 @@ def validate_mobile(mobile: str) -> bool:
248248 Examples
249249 --------
250250 To check if '9999999999' is a valid mobile number
251- >>> print(validate_mobile ('9999999999'))
251+ >>> print(is_mobile_valid ('9999999999'))
252252 True
253253 """
254254 match = re .match (r"^[6-9]\d{9}$" , str (mobile ))
255255 if match is None :
256- raise ValidationError ("Invalid Mobile Number " )
256+ raise ValidationError ("Enter a valid mobile number. " )
257257 return True
258258
259259
@@ -281,8 +281,8 @@ def validate_otp(*, destination: str, otp_val: int) -> bool:
281281 except OTPValidation .DoesNotExist as e :
282282 raise NotFound (
283283 detail = _ (
284- "No pending OTP validation request found for provided destination."
285- " Kindly send an OTP first"
284+ f "No pending OTP validation request found for provided { destination } ."
285+ " Kindly send an OTP first. "
286286 )
287287 ) from e
288288
@@ -350,7 +350,7 @@ def send_message(
350350
351351 if recip_mobile :
352352 # check for valid mobile numbers
353- validate_mobile (recip_mobile )
353+ is_mobile_valid (recip_mobile )
354354
355355 try :
356356 send_mail (
@@ -361,7 +361,8 @@ def send_message(
361361 recipient_list = [recip_email ],
362362 )
363363 except Exception as e : # noqa
364- sent ["message" ] = f"Email Message sending failed! { str (e .args )} "
364+ logger .error ("Email sending failed" , exc_info = e )
365+ sent ["message" ] = str (e )
365366 sent ["success" ] = False
366367 else :
367368 sent ["message" ] = "Email Message sent successfully!"
@@ -371,8 +372,8 @@ def send_message(
371372 try :
372373 api .send_sms (body = message , to = recip_mobile , from_phone = None )
373374 except Exception as e : # noqa
374- logger .debug ("Message sending failed" , exc_info = e )
375- sent ["mobile_message" ] = f"Mobile Message sending failed! { str (e . args ) } "
375+ logger .error ("Message sending failed" , exc_info = e )
376+ sent ["mobile_message" ] = str (e )
376377 else :
377378 sent ["mobile_message" ] = "Mobile Message sent successfully!"
378379
0 commit comments