Last active
January 30, 2016 10:02
-
-
Save mactkg/c9c6a04807e3b1e11876 to your computer and use it in GitHub Desktop.
You can use this feature at this branch: https://github.com/mactkg/Gyazo/tree/good-fail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/script.original b/script | |
index e46e48f..2d76e3a 100644 | |
--- a/script.original | |
+++ b/script | |
@@ -4,6 +4,13 @@ | |
require 'net/http' | |
require 'net/https' # for ruby 1.8.x | |
+def save_img(imgdata, filename=nil) | |
+ filename ||= "#{ENV['HOME']}/Desktop/Gyazo failed to upload at #{Time.now.to_s}.png" | |
+ File.open(filename, "w") do |file| | |
+ file.puts(imgdata) | |
+ end | |
+end | |
+ | |
begin | |
require 'json' | |
rescue LoadError | |
@@ -208,10 +215,12 @@ begin | |
@res = http.post(CGI, data, header) | |
end | |
rescue => e | |
+ save_img imagedata | |
abort("Failed to upload.\n#{e}") | |
end | |
if @res.code.to_i >= 400 | |
+ save_img imagedata | |
abort("Failed to upload.\n#{@res.code}: #{@res.message}") | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment