Skip to content

Commit

Permalink
more verbose message for missing configs on update-queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Simaris committed Apr 16, 2019
1 parent 99a28b1 commit 42be2d0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
16 changes: 16 additions & 0 deletions quit/web/modules/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,22 @@ def sparql(branch_or_ref):
else:
response.headers["X-CurrentCommit"] = commitid
return response
except KeyError as e:
logger.exception(e)
if "config value 'user.name' was not found" in e.args:
message = ("Unable to process query: "
"git config value 'user.name' was not found.\n"
"Pls use the following command in your data repo:"
"\n\n git config user.name <your name>")
return make_response(message, 400)
if "config value 'user.email' was not found" in e.args:
message = ("Unable to process query: "
"git config value 'user.name' was not found.\n"
"Pls use the following command in your data repo:"
"\n\n git config user.email <your email>")
return make_response(message, 400)
# KeyError has many sources -> it could be caused by other problems
return make_response('Error after executing the update query.', 400)
except Exception as e:
# query ok, but unsupported query type or other problem during commit
logger.exception(e)
Expand Down
16 changes: 15 additions & 1 deletion quit/web/modules/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,21 @@ def merge(refspec):
return response
else:
return "<pre>Unsupported Mimetype: {}</pre>".format(mimetype), 406

except KeyError as e:
message = "\n"
if "config value 'user.name' was not found" in e.args:
message += ("Unable to process query: "
"git config value 'user.name' was not found.\n"
"Pls use the following command in your data repo:"
"\n\n git config user.name <your name>")
if "config value 'user.email' was not found" in e.args:
message += ("Unable to process query: "
"git config value 'user.name' was not found.\n"
"Pls use the following command in your data repo:"
"\n\n git config user.email <your email>")
logger.error(e)
logger.error(traceback.format_exc())
return "<pre>" + traceback.format_exc() + message + "</pre>", 400
except Exception as e:
logger.error(e)
logger.error(traceback.format_exc())
Expand Down

0 comments on commit 42be2d0

Please sign in to comment.