summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Friedli2020-08-22 14:01:00 +0200
committerjfriedli2020-09-06 08:29:17 -0700
commit7a252eaa907a71dfdc5c8b408659be3352a52c20 (patch)
treeef6f7e742b1129926bde0a2a3962ee1355b24aac
parenta768cf322726a3cbb56c5eda8958402dd34b012f (diff)
added error logging in api
-rw-r--r--matweb/rest_api.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/matweb/rest_api.py b/matweb/rest_api.py
index 72da1cd..1e7f9fd 100644
--- a/matweb/rest_api.py
+++ b/matweb/rest_api.py
@@ -92,22 +92,27 @@ class APIClean(Resource):
92 @swag_from('./oas/remove_metadata.yml') 92 @swag_from('./oas/remove_metadata.yml')
93 def post(self): 93 def post(self):
94 if 'file' not in request.files: 94 if 'file' not in request.files:
95 current_app.logger.error('Clean - No file part')
95 abort(400, message='No file part') 96 abort(400, message='No file part')
96 97
97 uploaded_file = request.files['file'] 98 uploaded_file = request.files['file']
98 if not uploaded_file.filename: 99 if not uploaded_file.filename:
100 current_app.logger.error('Clean - No selected `file`')
99 abort(400, message='No selected `file`') 101 abort(400, message='No selected `file`')
100 try: 102 try:
101 filename, filepath = utils.save_file(uploaded_file, current_app.config['UPLOAD_FOLDER']) 103 filename, filepath = utils.save_file(uploaded_file, current_app.config['UPLOAD_FOLDER'])
102 except ValueError: 104 except ValueError:
105 current_app.logger.error('Clean - Invalid Filename')
103 abort(400, message='Invalid Filename') 106 abort(400, message='Invalid Filename')
104 107
105 parser, mime = utils.get_file_parser(filepath) 108 parser, mime = utils.get_file_parser(filepath)
106 109
107 if parser is None: 110 if parser is None:
111 current_app.logger.error('Clean - The type %s is not supported', mime)
108 abort(415, message='The type %s is not supported' % mime) 112 abort(415, message='The type %s is not supported' % mime)
109 113
110 if parser.remove_all() is not True: 114 if parser.remove_all() is not True:
115 current_app.logger.error('Clean - Unable to clean %s', mime)
111 abort(500, message='Unable to clean %s' % mime) 116 abort(500, message='Unable to clean %s' % mime)
112 117
113 _, _, _, output_filename = utils.cleanup(parser, filepath, current_app.config['UPLOAD_FOLDER']) 118 _, _, _, output_filename = utils.cleanup(parser, filepath, current_app.config['UPLOAD_FOLDER'])