Skip to content

Instantly share code, notes, and snippets.

@davidhamann
Created June 25, 2018 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidhamann/998c2babf6b0aafa1571a28344f36250 to your computer and use it in GitHub Desktop.
Save davidhamann/998c2babf6b0aafa1571a28344f36250 to your computer and use it in GitHub Desktop.
How to handle FMS errors in python-fmrest.
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