shogi-server source
Revisão | 29968bc75167d7fe325041225fe89b9adffea571 (tree) |
---|---|
Hora | 2013-11-24 12:05:52 |
Autor | Daigo Moriwaki <daigo@debi...> |
Commiter | Daigo Moriwaki |
* [shogi-server] - shogi_server/league/floodgate.rb: Improved robustness against empty file under ruby 1.9.3p194
@@ -1,3 +1,9 @@ | ||
1 | +2013-11-24 Daigo Moriwaki <daigo at debian dot org> | |
2 | + | |
3 | + * [shogi-server] | |
4 | + - shogi_server/league/floodgate.rb: Improved robustness against | |
5 | + empty file under ruby 1.9.3p194 | |
6 | + | |
1 | 7 | 2013-11-23 Daigo Moriwaki <daigo at debian dot org> |
2 | 8 | |
3 | 9 | * [mk_rate] |
@@ -216,8 +216,13 @@ class League | ||
216 | 216 | def load |
217 | 217 | return unless @file.exist? |
218 | 218 | |
219 | - @records = YAML.load_file(@file) | |
220 | - unless @records && @records.instance_of?(Array) | |
219 | + begin | |
220 | + @records = YAML.load_file(@file) | |
221 | + unless @records && @records.instance_of?(Array) | |
222 | + $logger.error "%s is not a valid yaml file. Instead, an empty array will be used and updated." % [@file] | |
223 | + @records = [] | |
224 | + end | |
225 | + rescue | |
221 | 226 | $logger.error "%s is not a valid yaml file. Instead, an empty array will be used and updated." % [@file] |
222 | 227 | @records = [] |
223 | 228 | end |