Created
January 30, 2012 15:28
-
-
Save ldaniel/1704970 to your computer and use it in GitHub Desktop.
Tratando erros no Ruby
This file contains 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
tarifacao = File.open(arquivo, "w") | |
begin | |
# excecoes serao capturadas apos o 'begin' | |
while data = socket.read(512) | |
tarifacao.write(data) | |
end | |
# Trata alguma excecao | |
rescue SystemCallError | |
$stderr.print "Erro de IO: " + $! | |
opFile.close | |
File.delete(arquivo) | |
raise | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment