Tag: ruby

Ruby

Ensure with Explicit Return

Consider the following method. Assume that the call to thing.method_that_possibly_raises! might raise an app exception we will call SomeAppException? What we have here is a code smell. Let’s consider what ensure does. The ensure clause in Ruby…

Custom Error Handling in Rails

1. Create an ErrorsController in app/controllers class ErrorsController < ApplicationController  def not_found   respond_to do |format|    format.html { render template: “errors/not_found”,               layout: “layouts/application”,               status: 404 }   end  end  def…