Where to define custom error types in Ruby and/or Rails?

后端 未结 5 2078
礼貌的吻别
礼貌的吻别 2020-12-12 10:10

Is there a best practice for defining custom error types in a Ruby library (gem) or Ruby on Rails application? Specifically:

  1. Where do they belong structurally
5条回答
  •  伪装坚强ぢ
    2020-12-12 10:56

    in rails you can make app/errors directory

    # app/errors/foo_error.rb
    class FooError < StandardError; end
    

    restart spring/server and it should pick it up

提交回复
热议问题