1 from django.http import JsonResponse
3 from filex.ftp import FTPException
6 class FTPMiddleware(object):
7 def process_exception(self, request, exception):
8 if isinstance(exception, FTPException):
9 message = exception.message
12 if 'No such file or directory' in message:
14 elif 'Permission denied' in message:
17 return JsonResponse({'error': message}, status=status)