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 +4 -4
- data/README.md +22 -2
- data/lib/api_exception/base_exception.rb +1 -1
- data/lib/api_exception/controller_exception.rb +1 -1
- data/lib/api_exception/file_exception.rb +1 -1
- data/lib/api_exception/model_exception.rb +1 -1
- data/lib/api_exception/request_exception.rb +1 -1
- data/lib/api_exception/user_exception.rb +1 -1
- data/lib/api_exception/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aeefc2868036a903c5bf6f66723a5e25a7cd422a7922a34cb67f715a9c83a96f
|
4
|
+
data.tar.gz: c8577f4396e3405903c615a6a04455ef47b6ef302968f9ea1ea7da830848f23e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
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.
|
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-
|
11
|
+
date: 2025-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|