rubyのTimeout::Errorにはまってしまったので、記録しておきます。 net/httpを使ってWebサーバに接続するデーモンプログラムを書いていました。例外はすべてキャッチするつもりでrescueを書いていました。 require 'net/http' begin Net::HTTP.start("www.foo") do |http| ... end rescue =>e # エラータイプを省略 ... end しかし、net/httpではTimeout::Error例外を発生させるではありませんか。 しかもさらに悪いことに、接続先のサーバはめったにタイムアウトしないのでTimeout::Errorが発生することに気がつきませんでした。 いろいろ調べてみると、 rescueはエラータイプを省略するとStandartErrorのサブクラスの例外を捕捉する Timeout::Er
I’ve know that str.split had an idiom which split strings into characters (by default, bytes in Ruby 1.8) if passed a regular expression that matched a zero-width string, thus: string.split(//) What I didn’t know was that this idiom was sensitive to either the encoding of the regular expression (example: //u) or the value of KCODE. But that’s not the most important part. The interesting thing is
現在の Unix システムでの最大時刻は、協定世界時の2038年1月19日午前3時14分7秒です。 http://www.ruby-lang.org/ja/man/?cmd=view;name=Time Timeは2038/1/19以降がエラーになる。 >> Time.gm(2038,1,19).strftime("%Y-%m-%d %a") => "2038-01-19 Tue" >> Time.gm(2038,1,20).strftime("%Y-%m-%d %a") ArgumentError: time out of range from (irb):7:in `gm' from (irb):7 from :0DateTimeはもっとずっと先まで大丈夫。 >> require 'date' => true >> DateTime.civil(2038,1,19).strftime(
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く