api_exception 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98dabbff847276d241f8b6339317135669ea5001b75d936bbc42fc9f001dbcde
4
- data.tar.gz: 5d1423c28d88c359b727c1de12b76ae593382d6155966644aae31cca6b6352e2
3
+ metadata.gz: aeefc2868036a903c5bf6f66723a5e25a7cd422a7922a34cb67f715a9c83a96f
4
+ data.tar.gz: c8577f4396e3405903c615a6a04455ef47b6ef302968f9ea1ea7da830848f23e
5
5
  SHA512:
6
- metadata.gz: e9554a7292def309a58d54af58e6ad235069dbacd75a5c5c9ea494f55b89310e4e5a7ce610fe408e58795be5b6d656209139cdef1eb4c30fe202e4c1ed375540
7
- data.tar.gz: 7acb28722554c9864bc66154a8ad8a2fe7e655d9f75a0d1c4e4d83c3826aa1f39ec67f45858fd369c0f330cf21c0d5b45380f7ac45cc9339a8de5a1c8d6b8610
6
+ metadata.gz: 683d5ca3828d37482ae74f8641180faba8b857f202895f5ea6ad77f9c12a5393b7a6b2328ed08eb578d9fcbec93db29419ae22b2a170cc2a056f7cab50aa5b66
7
+ data.tar.gz: 31ac7672a69b290f52378021e5aba39508f17617521a67542cec546605b24c6a5d04b580f166452eb122d49687d110a405a3be1953727dc723d05d87f6b0c2d2
data/README.md CHANGED
@@ -10,11 +10,31 @@ ApiException::BaseException
10
10
  # You can initialize with the following params
11
11
  # error_type -> This argument should be a symbol
12
12
  # errors -> This argument should be an array of string errors
13
- # params -> Should be a hash as params for I18n.t translations
14
- # platform -> Should specify where this error is rendered from, 'API' value is by default
13
+ # params -> Should be a hash as params for I18n.t translations (optional)
14
+ # platform -> Should specify where this error is rendered from, 'API' value is by default (optional)
15
15
  ApiException::BaseException.new(:UNKNOWN_ERROR, ["Something went wrong"], { process: "" })
16
16
  ```
17
17
 
18
+ ## Examples availables
19
+ ```ruby
20
+
21
+ ApiException::ModelException.new(:RECORD_NOT_FOUND, ["Item not found"], { model: "User"})
22
+ #=> Record not found for User (ApiException::ModelException)
23
+
24
+ ApiException::ControllerException.new(:INVALID_PARAMS, ["cant parse body params"])
25
+ #=> The provided params are invalid (ApiException::ControllerException)
26
+
27
+ ApiException::FileException.new(:UNSUPPORTED_FILE, ["wrong file extension"])
28
+ #=> The file you are trying to upload is not supported (ApiException::FileException)
29
+
30
+ ApiException::RequestException.new(:TIMEOUT, ["Server response time exceed"], { timeout: "3 mins"})
31
+ #=> The response timeout was exceeded: 3 mins (ApiException::RequestException)
32
+
33
+ ApiException::UserException.new(:DUPLICATED_USER, ["user data already exist"])
34
+ #=> Duplicate user (ApiException::UserException)
35
+
36
+ ```
37
+
18
38
  ## Installation
19
39
  Add this line to your application's Gemfile:
20
40
 
@@ -5,7 +5,7 @@ module ApiException
5
5
 
6
6
  attr_reader :code, :message, :errors, :type, :error_type
7
7
 
8
- def initialize(error_type, errors, params, platform = "API")
8
+ def initialize(error_type, errors, params = {}, platform = "API")
9
9
  @error = error_code_map[error_type]
10
10
 
11
11
  define_attributes(error_type, errors, params, platform)
@@ -1,7 +1,7 @@
1
1
  module ApiException
2
2
  class ControllerException < BaseException
3
3
 
4
- def initialize(error_type, errors, params, platform = "API")
4
+ def initialize(error_type, errors, params = {}, platform = "API")
5
5
  super
6
6
  end
7
7
 
@@ -1,7 +1,7 @@
1
1
  module ApiException
2
2
  class FileException < BaseException
3
3
 
4
- def initialize(error_type, errors, params, platform = "API")
4
+ def initialize(error_type, errors, params = {}, platform = "API")
5
5
  super
6
6
  end
7
7
 
@@ -1,7 +1,7 @@
1
1
  module ApiException
2
2
  class ModelException < BaseException
3
3
 
4
- def initialize(error_type, errors, params, platform = "API")
4
+ def initialize(error_type, errors, params = {}, platform = "API")
5
5
  super
6
6
  end
7
7
 
@@ -1,7 +1,7 @@
1
1
  module ApiException
2
2
  class RequestException < BaseException
3
3
 
4
- def initialize(error_type, errors, params, platform = "API")
4
+ def initialize(error_type, errors, params = {}, platform = "API")
5
5
  super
6
6
  end
7
7
 
@@ -1,7 +1,7 @@
1
1
  module ApiException
2
2
  class UserException < BaseException
3
3
 
4
- def initialize(error_type, errors, params, platform = "API")
4
+ def initialize(error_type, errors, params = {}, platform = "API")
5
5
  super
6
6
  end
7
7
 
@@ -2,5 +2,5 @@ module ApiException
2
2
  # first number stable version
3
3
  # second number major release
4
4
  # bug fixes or minor release
5
- VERSION = "1.1.2"
5
+ VERSION = "1.1.3"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_exception
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - killjoy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-27 00:00:00.000000000 Z
11
+ date: 2025-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails