mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-24 10:35:46 +03:00
Return INVALID_PARAM if phone number cannot be parsed
This commit is contained in:
parent
93bd033fbe
commit
80dc51171f
1 changed files with 2 additions and 2 deletions
|
@ -21,7 +21,7 @@
|
|||
|
||||
import phonenumbers
|
||||
|
||||
from synapse.api.errors import SynapseError
|
||||
from synapse.api.errors import SynapseError, Codes
|
||||
|
||||
|
||||
def phone_number_to_msisdn(country: str, number: str) -> str:
|
||||
|
@ -45,7 +45,7 @@ def phone_number_to_msisdn(country: str, number: str) -> str:
|
|||
try:
|
||||
phoneNumber = phonenumbers.parse(number, country)
|
||||
except phonenumbers.NumberParseException:
|
||||
raise SynapseError(400, "Unable to parse phone number")
|
||||
raise SynapseError(400, "Unable to parse phone number", Codes.INVALID_PARAM)
|
||||
return phonenumbers.format_number(phoneNumber, phonenumbers.PhoneNumberFormat.E164)[
|
||||
1:
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue