about summary refs log tree commit diff
path: root/lib/exceptions.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-03-19 02:42:43 +0100
committerGitHub <noreply@github.com>2021-03-19 02:42:43 +0100
commita4dcaef53b97c58fd153de6f151b6fada40f3442 (patch)
treee9c0b360e421c31e4e873de03424fd9721dd7fee /lib/exceptions.rb
parent5027abecd1e5e511064de75fb5248139e1c8fe23 (diff)
Prepare Mastodon for zeitwerk autoloader (#15917)
* Prepare Mastodon for zeitwerk autoloader (Rails 6)

Add inflections and rename/move a few classes.

In particular, app/lib/exceptions.rb and app/lib/sanitize_config.rb
were manually loaded while still in autoload paths.

* Add inflection for Url → URL
Diffstat (limited to 'lib/exceptions.rb')
-rw-r--r--lib/exceptions.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/exceptions.rb b/lib/exceptions.rb
new file mode 100644
index 000000000..7c8e77871
--- /dev/null
+++ b/lib/exceptions.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Mastodon
+  class Error < StandardError; end
+  class NotPermittedError < Error; end
+  class ValidationError < Error; end
+  class HostValidationError < ValidationError; end
+  class LengthValidationError < ValidationError; end
+  class DimensionsValidationError < ValidationError; end
+  class StreamValidationError < ValidationError; end
+  class RaceConditionError < Error; end
+  class RateLimitExceededError < Error; end
+
+  class UnexpectedResponseError < Error
+    def initialize(response = nil)
+      if response.respond_to? :uri
+        super("#{response.uri} returned code #{response.code}")
+      else
+        super
+      end
+    end
+  end
+end