Skip to content

Commit

Permalink
Added error regarding empty gist content
Browse files Browse the repository at this point in the history
  • Loading branch information
condemil committed Aug 8, 2013
1 parent f23b149 commit 3060c98
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gist.py
Expand Up @@ -140,6 +140,11 @@ def _fn(*args, **kwargs):


def create_gist(public, description, files):
for filename, text in list(files.items()):
if not text:
sublime.error_message("Gist: Unable to create a Gist with empty content")
return

file_data = dict((filename, {'content': text}) for filename, text in list(files.items()))
data = json.dumps({'description': description, 'public': public, 'files': file_data})
gist = api_request(GISTS_URL, data)
Expand Down Expand Up @@ -437,6 +442,9 @@ def on_gist_filename(filename):

gist = create_gist(self.public, description, gist_data)

if not gist:
return

gist_html_url = gist['html_url']
sublime.set_clipboard(gist_html_url)
sublime.status_message("%s Gist: %s" % (self.mode(), gist_html_url))
Expand Down

0 comments on commit 3060c98

Please sign in to comment.