https://pantsbuild.org/ logo
f

fast-nail-55400

12/03/2021, 8:22 PM
how do I use
UnparsedAddressInputs
or
AddressInput.parse
to parse address strings in a way that does not throw an exception if the string is not parseable as an address? (context is I want to have a fallback way to parse those strings as JVM coordinate strings if they are not parseable as addresses.) I don’t see None returned anywhere so I assume
AddressInput.parse
raises exceptions
h

hundreds-father-404

12/03/2021, 8:24 PM
yeah it raises exception. do you specifically want to handle failure if the address does not exist? vs if the string is not parseable as an address?
f

fast-nail-55400

12/03/2021, 8:26 PM
I want to handle both. If it is a valid address but there is no target there, it should error. But if it is not parsable as an address then I’d like to fallback to treating it as a coordinate string.
I could do the inverse and check if it is a coordinate string (colon-separated and three fields) first.
h

hundreds-father-404

12/03/2021, 8:27 PM
K, then you can use
AddressInput.parse()
with a try/except. Then use
await Get(Address, AddressInput, address_input)
f

fast-nail-55400

12/03/2021, 8:28 PM
ok