{"id":2712,"date":"2023-05-08T03:44:52","date_gmt":"2023-05-08T03:44:52","guid":{"rendered":"https:\/\/beon.tech\/blog\/?p=2712"},"modified":"2026-05-22T10:18:44","modified_gmt":"2026-05-22T13:18:44","slug":"how-to-handle-exceptions-in-rails-full-guide","status":"publish","type":"post","link":"https:\/\/beon.tech\/blog\/how-to-handle-exceptions-in-rails-full-guide\/","title":{"rendered":"How to handle exceptions in Rails\u2014A Practical Guide"},"content":{"rendered":"\n<p>We often encounter exceptions in Ruby on Rails, that if we don&#8217;t manage correctly from the beginning, can cause problems and time waste. But solving them doesn\u2019t have to be so tedious! This article provides an overview of how to handle exceptions in Ruby on Rails, helping you implement strategies and best practices to do it efficiently.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The problem with Ruby on Rails exceptions<\/h2>\n\n\n\n<p>Picture this: you&#8217;re working with some code that needs to make many different validations and you should return specific error messages or even specific status codes for each case. Let&#8217;s say we are making a user signup validation that will check if the email and the password are present it would look like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def validate!(user)\n\tif user[:email] &amp;&amp; user[:password]\n\t\tputs \"Great the user is present\"\n\telse\n\t\traise \"Some attribute is missing but we don't know which\"\n\tend\nend<\/pre>\n\n\n\n<p>while the exception handler at the ApplicationController would look like the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class ApplicationController &lt; ActionController::Base\n\trescue_from StandardError, with: :handle_errors\n\n\tdef handle_errors(e)\n\t\trender json: { message: e.message }, status: 500\n\tend\nend\n<\/pre>\n\n\n\n<p>Okay let&#8217;s be honest\u2014in the example above, we are not being very specific about what are we missing. So, let&#8217;s make a couple changes to improve it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Initial changes to produce clearer messages for Ruby on Rails exceptions<\/h2>\n\n\n\n<p>The following is a better alternative to what we saw before:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def validate(user)\n\tif !user[:email]\n\t\traise \"Email is not present\"\n\telse if !user[:password]\n\t\traise \"Password is not present\"\n\tend\n\n\tputs \"Great the user is present\"\nend\n<\/pre>\n\n\n\n<p>With this, we would be returning clearer error messages. But there&#8217;s still one issue with the code above, the handler is always sending a 500 status which could apply for some errors but not for the ones that we are throwing, in this case it would be better to respond with 400 that states for <strong>Bad Request<\/strong>, 406 that states for <strong>Not Acceptable<\/strong> or even 422 for an <strong>Unprocessable Entity<\/strong>, and at this point we have some options to take, one of them being defining our own exceptions like in the following example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class InvalidUser &lt; StandardError\nend<\/pre>\n\n\n\n<p>Which could be then implemented like this<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># ApplicationController\nrescue_from InvalidUser do |e|\n\trender json { message: e.message }, status: 422\nend\n\n# Validate user\ndef validate(user)\n\terror = nil\n\tif !user[:email]\n\t\terror = \"Email is not present\"\n\telsif !user[:password]\n\t\terror = \"Password is not present\"\n\tend\n\n\treturn InvalidUser.new(error) if error\n\n\tputs \"Great the user is present\"\nend\n<\/pre>\n\n\n\n<p>Well, that looks way better. But what happens when we need to add many different exception classes?<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why we need to go a step further to handle exceptions in Ruby on Rails<\/h2>\n\n\n\n<p>We need to be more granular about what to do if a user transaction fails and know how to handle a rollback action in a exception handler, or we would end with tons exception class files in the project and with a lot of different handlers in the top of the application.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># ApplicationController\nrescue_from InvalidUser #...\nrescue_from InvalidTransaction #...\n# Project structure\n| lib\n|-- exceptions\n|--|-- invalid_user.rb\n|--|-- invalid_transaction.rb\n|--|-- etc...<\/pre>\n\n\n\n<p>As defining the class also implies creating the file and modifying the handlers, sometimes it&#8217;s easier for a team to not define any and return generic errors instead or even defining the exceptions in the same class of the service that is going to use them, which just increases the complexity of the class and is not convenient for the cases when we need to reuse the exception, because we would need to access it through the service as ValidateUserService::InvalidUser which would also increase the coupling between the classes, and would make it harder to refactor.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class ValidateUserService\nclass InvalidUser &lt; StandardError\nend\n# ...\nend<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>The solution<\/strong><\/h2>\n\n\n\n<p>In order to reduce the project files, and defining a framework for adding exceptions we can create a file which is going to store the configuration of each exception, that will contain the <strong>message<\/strong>, <strong>http_code<\/strong>, and any other information we find useful for debugging or for context, for example I like to add an internal code that could help for communication between a CS and a development team.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Defining the configuration<\/strong><\/h3>\n\n\n\n<p>For this I&#8217;m going to use yaml (this is a personal preference because it doesn&#8217;t need neither brackets nor quotation marks) but you can use any other type of file that can be parsed as a hash in ruby.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">invalid_user:\n\tmessage: The user is not valid\n\tstatus: !ruby\/symbol unprocessable_entity\n\thttp_code: 422\n\tcode: 10001\ninvalid_transaction:\n\tmessage: The transaction is not valid\n\tstatus: !ruby\/symbol not_acceptable\n\thttp_code: 406\n\tcode: 10002\n<\/pre>\n\n\n\n<p>Now we need to define a class that will act as the intermediary between the definition file and our code, it will be called CustomException but you can use any name that results more convenient for your case.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Exceptions entrypoint<\/strong><\/h3>\n\n\n\n<p id=\"block-c2996292-139e-49f5-9b62-95e3cde52e85\">As I&#8217;m using yaml, I added this gem to parse it into a hash:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class CustomException &lt; StandardError\n\tEXCEPTIONS_PATH = '.\/exceptions.yaml'\n\n  attr_accessor :config, :status, :code, :message, :http_code, :errors\n\n  def initialize(config)\n\t  # set the config object for debugging purposes\n    @config = config\n    set_defaults(config)\n  end\n\n  def set_defaults(config)\n    @code = config['code']\n    @status = config['status']\n    @message = config['message']\n    @http_code = config['http_code']\n    @errors = config['errors'] || [@message]\n  end<\/pre>\n\n\n\n<p>This will be used in the exception handler to return a custom status<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp;&nbsp;def response_objec\n{\ncode: code,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;status: status,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;message: message,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errors: errors,\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http_code: http_code\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;end\n&nbsp;&nbsp;class &lt;&lt; self\n&nbsp; # This will be called each time that a non defined class is invoked\n&nbsp;&nbsp;&nbsp;&nbsp;def const_missing(name)\nundesrcored_const = name.to_s.underscore\nraise \"Exception Not Defined\" unless exists?(undesrcored_const)\nerr_hash = exceptions[undesrcored_const]\n# Here we define the new class as a child of CustomException\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const_set(name, Class.new(CustomException) do\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;define_method :initialize do |errors = nil|\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;super(err_hash.merge(\"errors\" =&gt; errors))\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end\n  &nbsp;&nbsp;&nbsp;&nbsp;end)\n&nbsp;&nbsp;&nbsp;&nbsp;end\ndef exists?(name)\nexceptions.include?(name)\nend\n# Here we are reading the exception definitions from the config file\ndef exceptions\n@exceptions ||= File.read(EXCEPTIONS_PATH).yield_self do |f|\nYAML.load(f) || {}\nend\nrescue StandardError\n{}\nend\n&nbsp;&nbsp;end\nend<\/pre>\n\n\n\n<p>With this we are set for our first exceptions which will be created dynamically defined when called, that can be raised and handled in the following way, returning to the user validation that we mentioned earlier in this article.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># ValidateUserService\ndef validate\n\t# ...\n\traise CustomException::Invaliduser if error\n\t# ...\nend\n\n# ApplicationController\nclass ApplicationController &lt; ActionController::Base\n\trescue_from CustomException do |e|\n\t\trender json { message: e.message, code: e.code }, status: e.status\n\tend\nend\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Improvements<\/strong><\/h3>\n\n\n\n<p>This solution can also be implemented with<a href=\"https:\/\/guides.rubyonrails.org\/i18n.html\"> i18n<\/a> which will help you to return translated messages for the different languages that your platform uses, you would only need to replace the configuration file for i18n and modify the const_missing&nbsp; method like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def const_missing(name)\n\tconst_set(name, Class.new(CustomException) do\n\t\tdefine_method :initialize do |errors = nil|\n\t\t\tI18n.reload!\n\t\t\tI18n.locale = :en\n\t\t\terr_hash = I18n.t(\"custom_exception.#{name.to_s.underscore}\")\n\t\t\tsuper(err_hash.merge(errors: errors))\n\t\tend\n\tend\nend\n<\/pre>\n\n\n\n<p>The original idea behind the errors attribute is to provide more context about the errors, for example, having only one InvalidUser exception with the message <em>The User is invalid<\/em> and accessing the error attribute to find the Missing Email or Missing Password<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final thoughts<\/h2>\n\n\n\n<p>I hope you find this guide useful. But always remember, no solution is perfect or fits everywhere. Before implementing this, make sure that it does not interfere with the practices and standards of your organization or your team. We will be reviewing more topics related to metaprogramming in the next articles.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We often encounter exceptions in Ruby on Rails, that if we don&#8217;t manage correctly from the beginning, can cause problems and time waste. But solving them doesn\u2019t have to be so tedious! This article provides an overview of how to handle exceptions in Ruby on Rails, helping you implement strategies and best practices to do<a class=\"read_more_linkk\" href=\"https:\/\/beon.tech\/blog\/how-to-handle-exceptions-in-rails-full-guide\/\">&#8230;<\/a><\/p>\n","protected":false},"author":29,"featured_media":2713,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[168],"tags":[437,473,156],"class_list":["post-2712","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical-engineering","tag-coding","tag-ruby-on-rails","tag-software-development"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>2023 Guide: Handling Exceptions in Rails | BEON.tech - Blog<\/title>\n<meta name=\"description\" content=\"Frustrated by Ruby on Rails errors? Discover efficient exception handling techniques. Read on to master best practices.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/beon.tech\/blog\/how-to-handle-exceptions-in-rails-full-guide\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"2023 Guide: Handling Exceptions in Rails | BEON.tech - Blog\" \/>\n<meta property=\"og:description\" content=\"Frustrated by Ruby on Rails errors? Discover efficient exception handling techniques. Read on to master best practices.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/beon.tech\/blog\/how-to-handle-exceptions-in-rails-full-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"Software &amp; Tech Hiring Insights | BEON.tech Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-08T03:44:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-22T13:18:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/beon.tech\/blog\/wp-content\/uploads\/2023\/05\/Diseno-sin-titulo34.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"470\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"German Reynaga\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@beontechok\" \/>\n<meta name=\"twitter:site\" content=\"@beontechok\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"German Reynaga\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/beontech.wpengine.com\\\/how-to-handle-exceptions-in-rails-full-guide\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/beontech.wpengine.com\\\/how-to-handle-exceptions-in-rails-full-guide\\\/\"},\"author\":{\"name\":\"German Reynaga\",\"@id\":\"https:\\\/\\\/beon.tech\\\/blog\\\/#\\\/schema\\\/person\\\/bf7e49c82784540f2082cb239cb792c5\"},\"headline\":\"How to handle exceptions in Rails\u2014A Practical Guide\",\"datePublished\":\"2023-05-08T03:44:52+00:00\",\"dateModified\":\"2026-05-22T13:18:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/beontech.wpengine.com\\\/how-to-handle-exceptions-in-rails-full-guide\\\/\"},\"wordCount\":838,\"image\":{\"@id\":\"https:\\\/\\\/beontech.wpengine.com\\\/how-to-handle-exceptions-in-rails-full-guide\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/beon.tech\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Diseno-sin-titulo34.png\",\"keywords\":[\"Coding\",\"Ruby on Rails\",\"Software Development\"],\"articleSection\":[\"Technical Engineering\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/beontech.wpengine.com\\\/how-to-handle-exceptions-in-rails-full-guide\\\/\",\"url\":\"https:\\\/\\\/beontech.wpengine.com\\\/how-to-handle-exceptions-in-rails-full-guide\\\/\",\"name\":\"2023 Guide: Handling Exceptions in Rails | BEON.tech - Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/beon.tech\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/beontech.wpengine.com\\\/how-to-handle-exceptions-in-rails-full-guide\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/beontech.wpengine.com\\\/how-to-handle-exceptions-in-rails-full-guide\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/beon.tech\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Diseno-sin-titulo34.png\",\"datePublished\":\"2023-05-08T03:44:52+00:00\",\"dateModified\":\"2026-05-22T13:18:44+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/beon.tech\\\/blog\\\/#\\\/schema\\\/person\\\/bf7e49c82784540f2082cb239cb792c5\"},\"description\":\"Frustrated by Ruby on Rails errors? Discover efficient exception handling techniques. Read on to master best practices.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/beontech.wpengine.com\\\/how-to-handle-exceptions-in-rails-full-guide\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/beontech.wpengine.com\\\/how-to-handle-exceptions-in-rails-full-guide\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/beontech.wpengine.com\\\/how-to-handle-exceptions-in-rails-full-guide\\\/#primaryimage\",\"url\":\"https:\\\/\\\/beon.tech\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Diseno-sin-titulo34.png\",\"contentUrl\":\"https:\\\/\\\/beon.tech\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/05\\\/Diseno-sin-titulo34.png\",\"width\":1000,\"height\":470},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/beontech.wpengine.com\\\/how-to-handle-exceptions-in-rails-full-guide\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/beon.tech\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to handle exceptions in Rails\u2014A Practical Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/beon.tech\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/beon.tech\\\/blog\\\/\",\"name\":\"Software &amp; Tech Hiring Insights | BEON.tech Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/beon.tech\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/beon.tech\\\/blog\\\/#\\\/schema\\\/person\\\/bf7e49c82784540f2082cb239cb792c5\",\"name\":\"German Reynaga\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/beon.tech\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/1704221151270-96x96.jpeg\",\"url\":\"https:\\\/\\\/beon.tech\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/1704221151270-96x96.jpeg\",\"contentUrl\":\"https:\\\/\\\/beon.tech\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/1704221151270-96x96.jpeg\",\"caption\":\"German Reynaga\"},\"description\":\"German Reynaga Araiza is a seasoned Software Engineer with hands-on experience building hybrid and full-stack web applications, managing databases, and delivering end-to-end features. He has worked across backend and frontend development, and brings a versatile toolkit that spans JavaScript, PHP, and Ruby\u2014focused on building reliable products and scalable systems in collaborative, fast-paced teams.\",\"url\":\"https:\\\/\\\/beon.tech\\\/blog\\\/author\\\/germanraynaga\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"2023 Guide: Handling Exceptions in Rails | BEON.tech - Blog","description":"Frustrated by Ruby on Rails errors? Discover efficient exception handling techniques. Read on to master best practices.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/beon.tech\/blog\/how-to-handle-exceptions-in-rails-full-guide\/","og_locale":"en_US","og_type":"article","og_title":"2023 Guide: Handling Exceptions in Rails | BEON.tech - Blog","og_description":"Frustrated by Ruby on Rails errors? Discover efficient exception handling techniques. Read on to master best practices.","og_url":"https:\/\/beon.tech\/blog\/how-to-handle-exceptions-in-rails-full-guide\/","og_site_name":"Software &amp; Tech Hiring Insights | BEON.tech Blog","article_published_time":"2023-05-08T03:44:52+00:00","article_modified_time":"2026-05-22T13:18:44+00:00","og_image":[{"width":1000,"height":470,"url":"https:\/\/beon.tech\/blog\/wp-content\/uploads\/2023\/05\/Diseno-sin-titulo34.png","type":"image\/png"}],"author":"German Reynaga","twitter_card":"summary_large_image","twitter_creator":"@beontechok","twitter_site":"@beontechok","twitter_misc":{"Written by":"German Reynaga","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/beontech.wpengine.com\/how-to-handle-exceptions-in-rails-full-guide\/#article","isPartOf":{"@id":"https:\/\/beontech.wpengine.com\/how-to-handle-exceptions-in-rails-full-guide\/"},"author":{"name":"German Reynaga","@id":"https:\/\/beon.tech\/blog\/#\/schema\/person\/bf7e49c82784540f2082cb239cb792c5"},"headline":"How to handle exceptions in Rails\u2014A Practical Guide","datePublished":"2023-05-08T03:44:52+00:00","dateModified":"2026-05-22T13:18:44+00:00","mainEntityOfPage":{"@id":"https:\/\/beontech.wpengine.com\/how-to-handle-exceptions-in-rails-full-guide\/"},"wordCount":838,"image":{"@id":"https:\/\/beontech.wpengine.com\/how-to-handle-exceptions-in-rails-full-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/beon.tech\/blog\/wp-content\/uploads\/2023\/05\/Diseno-sin-titulo34.png","keywords":["Coding","Ruby on Rails","Software Development"],"articleSection":["Technical Engineering"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/beontech.wpengine.com\/how-to-handle-exceptions-in-rails-full-guide\/","url":"https:\/\/beontech.wpengine.com\/how-to-handle-exceptions-in-rails-full-guide\/","name":"2023 Guide: Handling Exceptions in Rails | BEON.tech - Blog","isPartOf":{"@id":"https:\/\/beon.tech\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/beontech.wpengine.com\/how-to-handle-exceptions-in-rails-full-guide\/#primaryimage"},"image":{"@id":"https:\/\/beontech.wpengine.com\/how-to-handle-exceptions-in-rails-full-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/beon.tech\/blog\/wp-content\/uploads\/2023\/05\/Diseno-sin-titulo34.png","datePublished":"2023-05-08T03:44:52+00:00","dateModified":"2026-05-22T13:18:44+00:00","author":{"@id":"https:\/\/beon.tech\/blog\/#\/schema\/person\/bf7e49c82784540f2082cb239cb792c5"},"description":"Frustrated by Ruby on Rails errors? Discover efficient exception handling techniques. Read on to master best practices.","breadcrumb":{"@id":"https:\/\/beontech.wpengine.com\/how-to-handle-exceptions-in-rails-full-guide\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/beontech.wpengine.com\/how-to-handle-exceptions-in-rails-full-guide\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/beontech.wpengine.com\/how-to-handle-exceptions-in-rails-full-guide\/#primaryimage","url":"https:\/\/beon.tech\/blog\/wp-content\/uploads\/2023\/05\/Diseno-sin-titulo34.png","contentUrl":"https:\/\/beon.tech\/blog\/wp-content\/uploads\/2023\/05\/Diseno-sin-titulo34.png","width":1000,"height":470},{"@type":"BreadcrumbList","@id":"https:\/\/beontech.wpengine.com\/how-to-handle-exceptions-in-rails-full-guide\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/beon.tech\/blog\/"},{"@type":"ListItem","position":2,"name":"How to handle exceptions in Rails\u2014A Practical Guide"}]},{"@type":"WebSite","@id":"https:\/\/beon.tech\/blog\/#website","url":"https:\/\/beon.tech\/blog\/","name":"Software &amp; Tech Hiring Insights | BEON.tech Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/beon.tech\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/beon.tech\/blog\/#\/schema\/person\/bf7e49c82784540f2082cb239cb792c5","name":"German Reynaga","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/beon.tech\/blog\/wp-content\/uploads\/2026\/03\/1704221151270-96x96.jpeg","url":"https:\/\/beon.tech\/blog\/wp-content\/uploads\/2026\/03\/1704221151270-96x96.jpeg","contentUrl":"https:\/\/beon.tech\/blog\/wp-content\/uploads\/2026\/03\/1704221151270-96x96.jpeg","caption":"German Reynaga"},"description":"German Reynaga Araiza is a seasoned Software Engineer with hands-on experience building hybrid and full-stack web applications, managing databases, and delivering end-to-end features. He has worked across backend and frontend development, and brings a versatile toolkit that spans JavaScript, PHP, and Ruby\u2014focused on building reliable products and scalable systems in collaborative, fast-paced teams.","url":"https:\/\/beon.tech\/blog\/author\/germanraynaga\/"}]}},"featured_image_src":"https:\/\/beon.tech\/blog\/wp-content\/uploads\/2023\/05\/Diseno-sin-titulo34.png","featured_image_src_square":"https:\/\/beon.tech\/blog\/wp-content\/uploads\/2023\/05\/Diseno-sin-titulo34.png","author_info":{"display_name":"German Reynaga","author_link":"https:\/\/beon.tech\/blog\/author\/germanraynaga\/"},"_links":{"self":[{"href":"https:\/\/beon.tech\/blog\/wp-json\/wp\/v2\/posts\/2712","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/beon.tech\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/beon.tech\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/beon.tech\/blog\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/beon.tech\/blog\/wp-json\/wp\/v2\/comments?post=2712"}],"version-history":[{"count":0,"href":"https:\/\/beon.tech\/blog\/wp-json\/wp\/v2\/posts\/2712\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/beon.tech\/blog\/wp-json\/wp\/v2\/media\/2713"}],"wp:attachment":[{"href":"https:\/\/beon.tech\/blog\/wp-json\/wp\/v2\/media?parent=2712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/beon.tech\/blog\/wp-json\/wp\/v2\/categories?post=2712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/beon.tech\/blog\/wp-json\/wp\/v2\/tags?post=2712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}