Skip to content

Commit

Permalink
Output exception message.
Browse files Browse the repository at this point in the history
  • Loading branch information
dstein64 committed May 23, 2022
1 parent 10d6e61 commit f193d69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion vimgolf/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.2
0.4.3
15 changes: 10 additions & 5 deletions vimgolf/vimgolf.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,10 @@ def run(args):
os.system('')

return Status.SUCCESS
except Exception:
except Exception as e:
logger.exception('{} execution failed'.format(GOLF_VIM))
write('The execution of {} has failed'.format(GOLF_VIM), stream=sys.stderr, color='red')
write(str(e), stream=sys.stderr, color='magenta')
return Status.FAILURE


Expand Down Expand Up @@ -625,10 +626,11 @@ def put(challenge_id):
# Sanitize and add leading dot
in_extension = '.{}'.format(re.sub(r'[^\w-]', '_', in_type))
out_extension = '.{}'.format(re.sub(r'[^\w-]', '_', out_type))
except Exception:
except Exception as e:
logger.exception('challenge retrieval failed')
write('The challenge retrieval has failed', stream=sys.stderr, color='red')
write('Please check the challenge ID on vimgolf.com', stream=sys.stderr, color='red')
write(str(e), stream=sys.stderr, color='magenta')
return Status.FAILURE

challenge = Challenge(
Expand Down Expand Up @@ -669,9 +671,10 @@ def list_(page=None, limit=LISTING_LIMIT):
break
listing = Listing(id=id_, name=name, n_entries=n_entries)
listings.append(listing)
except Exception:
except Exception as e:
logger.exception('challenge retrieval failed')
write('The challenge list retrieval has failed', stream=sys.stderr, color='red')
write(str(e), stream=sys.stderr, color='magenta')
return Status.FAILURE

for idx, listing in enumerate(listings):
Expand Down Expand Up @@ -781,10 +784,11 @@ class Showing:
write('End File', color='green')
write(showing.end_file, end=None)
write(separator)
except Exception:
except Exception as e:
logger.exception('challenge retrieval failed')
write('The challenge retrieval has failed', stream=sys.stderr, color='red')
write('Please check the challenge ID on vimgolf.com', stream=sys.stderr, color='red')
write(str(e), stream=sys.stderr, color='magenta')
return Status.FAILURE

return Status.SUCCESS
Expand All @@ -808,10 +812,11 @@ def diff(challenge_id):
# Sanitize and add leading dot
in_extension = '.{}'.format(re.sub(r'[^\w-]', '_', in_type))
out_extension = '.{}'.format(re.sub(r'[^\w-]', '_', out_type))
except Exception:
except Exception as e:
logger.exception('challenge retrieval failed')
write('The challenge retrieval has failed', stream=sys.stderr, color='red')
write('Please check the challenge ID on vimgolf.com', stream=sys.stderr, color='red')
write(str(e), stream=sys.stderr, color='magenta')
return Status.FAILURE
with tempfile.TemporaryDirectory() as workspace, working_directory(workspace):
infile = 'in'
Expand Down

0 comments on commit f193d69

Please sign in to comment.