Created
June 25, 2018 08:44
-
-
Save davidhamann/998c2babf6b0aafa1571a28344f36250 to your computer and use it in GitHub Desktop.
How to handle FMS errors in python-fmrest.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fmrest | |
from fmrest.exceptions import FileMakerError | |
fms = fmrest.Server('https://<some host>', | |
user='admin', | |
password='admin', | |
database='Planets', | |
layout='Planets', | |
) | |
fms.login() | |
find_query = [{'name': 'name with no match'}] | |
try: | |
foundset = fms.find(find_query) | |
print(foundset[0]['name']) | |
except FileMakerError: | |
# handle errors | |
# access error code (e.g. 401, not found) via fms.last_error property | |
print(f'Error {fms.last_error} occurred') | |
fms.logout() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment