title: Ruby rescue exception during multiple methods
body: <p>I have built a simple banking application, which is able to perform the usual operations; Deposit, Withdraw etc.</p>
  
  <p>My controller methods perform these operations and rescue exceptions that are raised by the account or other entities.</p>
  
  <p><strong>Here are some of these methods used in the controller code:</strong></p>
  
  <pre><code>def open(type, with:)
      account = create type, (holders.find with)
      add account
      init_yearly_interest_for account
      boundary.render AccountSuccessMessage.new(account)
    rescue ItemExistError =&gt; message
      boundary.render message
    end
  
    def deposit(amount, into:)
      account = find into
      account.deposit amount
      boundary.render DepositSuccessMessage.new(amount)
    rescue ItemExistError =&gt; message
      boundary.render message
    end
  
    def withdraw(amount, from:)
      account = find from
      init_limit_reset_for account unless account.breached?
      account.withdraw amount
      boundary.render WithdrawSuccessMessage.new(amount)
    rescue ItemExistError, OverLimit, InsufficientFunds =&gt; message
      boundary.render message
    end
  
    def get_balance_of(id)
      account = find id
      boundary.render BalanceMessage.new(account)
    rescue ItemExistError =&gt; message
      boundary.render message
    end
  
    def transfer(amount, from:, to:)
      donar = find from
      recipitent = find to
      init_limit_reset_for donar unless donar.breached?
      donar.withdraw amount
      recipitent.deposit amount
      boundary.render TransferSuccessMessage.new(amount)
    rescue ItemExistError, OverLimit, InsufficientFunds =&gt; message
      boundary.render message
    end
  
    def add_holder(id, to:)
      holder = holders.find id
      account = find to
      account.add_holder holder
      boundary.render AddHolderSuccessMessage.new(holder, account)
    rescue ItemExistError, HolderOnAccount =&gt; message
      boundary.render message
    end
  
    def get_transactions_of(id)
      transactions = (find id).transactions
      boundary.render TransactionsMessage.new(transactions)
    rescue ItemExistError =&gt; message
      boundary.render message
    end
  
    def get_accounts_of(id)
      holder = holders.find id
      accounts = store.select { |_, a| a.holder? holder }.values
      boundary.render DisplayAccountsMessage.new(accounts)
    rescue ItemExistError =&gt; message
      boundary.render message
    end
  </code></pre>
  
  <p>As you can see I am rescuing multiple errors during multiple methods, often the same errors are handled.</p>
  
  <p>Although this is working, I wonder if it is possible to refactor and handle these exceptions whenever any of the methods in the controller are called.</p>
  
  <p>So for example:</p>
  
  <pre><code>during: 
    open, deposit, withdraw
  rescue ItemExistError =&gt; message
    boundary.render message
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>