mirror of
https://github.com/fergalmoran/home-auto.git
synced 2026-02-19 06:04:16 +00:00
28 lines
684 B
Python
28 lines
684 B
Python
import logging
|
|
import traceback
|
|
|
|
from flask_restplus import Api
|
|
from sqlalchemy.orm.exc import NoResultFound
|
|
|
|
import settings
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
api = Api(version='1.0', title='Bitchmints Home Auto API',
|
|
description='Various home automation REST endpoints')
|
|
|
|
|
|
@api.errorhandler
|
|
def default_error_handler(e):
|
|
message = 'An unhandled exception occurred.'
|
|
log.exception(message)
|
|
|
|
if not settings.FLASK_DEBUG:
|
|
return {'message': message}, 500
|
|
|
|
|
|
@api.errorhandler(NoResultFound)
|
|
def database_not_found_error_handler(e):
|
|
log.warning(traceback.format_exc())
|
|
return {'message': 'A database result was required but none was found.'}, 404
|