Ruby exception handling

background

When I drew the exception handling of Ruby, it was necessary to use it properly according to the situation, so I summarized it as a memorandum.

begin rescue

begin
  1 / 0 //Raise an exception
rescue
  puts "An error has occurred"  
end  

raise

begin
  raise
rescue
  puts "An error has occurred"  
end 

retry

begin
  raise
rescue 
  retry //Re-execute begin processing
end  

ensure

begin
  //Normal processing
rescue => e
  //Exception handling
ensure
  //It will be executed for the time being
end

Recommended Posts

ruby exception handling
Ruby exception handling
About Ruby exception handling
[Ruby] Exception handling basics
Exception handling
Exception handling Exception
[Ruby] Exception handling in functions
Java exception handling?
About exception handling
About exception handling
[Java] Exception handling
☾ Java / Exception handling
Java exception handling
Java exception handling
[Ruby] Exception handling, give back if given
Exception handling practice (ArithmeticException)
Spring Boot exception handling
Ruby Learning # 28 Handling Errors
Classes that require exception handling
Java's first exception handling (memories)
[Java] Practice of exception handling [Exception]
[Java] About try-catch exception handling
exception
Java exception handling usage rules
Exception handling techniques in Java
[Rails] How to write exception handling?
Exception handling with a fluid interface
Step-by-step understanding of Java exception handling
[For Java beginners] About exception handling
Solving with Ruby AtCoder 1st Algorithm Practical Test A Exception Handling
Ruby learning 4
Ruby basics
Ruby learning 5
Ruby basics
Ruby Review 2
Ruby addition
Refactoring Ruby
Ruby learning 3
Ruby setting 2
Ruby problem ⑦
Self-made Exception
Ruby learning 2
Java (exception handling, threading, collection, file IO)
[Ruby] Block
Refactoring Ruby
ruby calculator
Tips for gRPC error handling in Ruby
Ruby learning 6
Ruby settings 1
Refactoring Ruby
Ruby basics
Ruby memo
Ruby learning 1
Ruby Review 1
[Ruby] Module
try-catch-finally exception handling How to use java
I want to design a structured exception handling
Questions in java exception handling throw and try-catch