strapi_ruby 0.1.0 → 0.1.1
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/CHANGELOG.md +3 -1
- data/README.md +2 -0
- data/lib/strapi_ruby/errors/client_error.rb +11 -7
- data/lib/strapi_ruby/errors/configuration_error.rb +1 -1
- data/lib/strapi_ruby/errors/error_text.yml +4 -1
- data/lib/strapi_ruby/errors/logger.rb +21 -0
- data/lib/strapi_ruby/version.rb +1 -1
- data/lib/strapi_ruby.rb +1 -1
- data/strapi_ruby-0.1.0.gem +0 -0
- data/strapi_ruby.gemspec +1 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b57f00940ff27f894585565de2df3b5df945331e961232b5588af966e1fe40b
|
4
|
+
data.tar.gz: f0c734f9fade77f6bdd03dd505cedd40acc3f798bc566f3753ec879b204a1c08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 366d106cf1f9e421d2205e962643c19dfad4971f035163efbe8e900787898e1fabc8d50669b00ac7921e2bfa9bbb1f9891aa41f183630b7050f29e77e150e91c
|
7
|
+
data.tar.gz: eb616feadc6c363b2f89d21735373b35cc5705b2f0c59345acd33bba67fba1711e40adef3dbb0129d241c0f2b2aecb7c5bf4b163bffe18112b7511e0ffd22a1d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -531,6 +531,8 @@ class JSONParsingError < ClientError
|
|
531
531
|
|
532
532
|
One way to handle errors and gracefuly degrade is using `.escape_empty_answer` and use a block to nest your data accessing code.
|
533
533
|
|
534
|
+
Errors will still be logged in red in console.
|
535
|
+
|
534
536
|
##### Definition
|
535
537
|
|
536
538
|
```ruby
|
@@ -1,46 +1,50 @@
|
|
1
1
|
module StrapiRuby
|
2
2
|
class ClientError < StandardError
|
3
|
+
def initialize(message)
|
4
|
+
super(message)
|
5
|
+
StrapiRuby.logger.error(message)
|
6
|
+
end
|
3
7
|
end
|
4
8
|
|
5
9
|
class ConnectionError < ClientError
|
6
10
|
def initialize(message)
|
7
|
-
super("
|
11
|
+
super("#{ErrorMessage.faraday_connection} #{message}")
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
11
15
|
class UnauthorizedError < ClientError
|
12
16
|
def initialize(message, status)
|
13
|
-
super("
|
17
|
+
super("#{ErrorMessage.strapi_server_status} #{status}: #{message}. Make sure your strapi_token is valid.")
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
17
21
|
class ForbiddenError < ClientError
|
18
22
|
def initialize(message, status)
|
19
|
-
super("
|
23
|
+
super("#{ErrorMessage.strapi_server_status} #{status}: #{message}. Make sure your strapi_token has the correct permissions or allow public access.")
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
23
27
|
class NotFoundError < ClientError
|
24
28
|
def initialize(message, status)
|
25
|
-
super("
|
29
|
+
super("#{ErrorMessage.strapi_server_status} #{status}: #{message}.")
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
29
33
|
class UnprocessableEntityError < ClientError
|
30
34
|
def initialize(message, status)
|
31
|
-
super("
|
35
|
+
super("#{ErrorMessage.strapi_server_status} #{status}: #{message}.")
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
35
39
|
class ServerError < ClientError
|
36
40
|
def initialize(message, status)
|
37
|
-
super("
|
41
|
+
super("#{ErrorMessage.strapi_server_status} #{status}: #{message}. Please try again later.")
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
41
45
|
class BadRequestError < ClientError
|
42
46
|
def initialize(message, status)
|
43
|
-
super("
|
47
|
+
super("#{ErrorMessage.strapi_server_status} #{status}: #{message}. Check parameters")
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
@@ -10,4 +10,7 @@ expected_string_symbol: Invalid argument type. Expected String or Symbol.
|
|
10
10
|
expected_integer: Invalid argument type. Expected Integer.
|
11
11
|
expected_proc: Invalid argument type. Expected Proc.
|
12
12
|
publication_state: Invalid argument. Expected :live or :preview.
|
13
|
-
pagination: Use a single pagination method, either by page or by offset
|
13
|
+
pagination: Use a single pagination method, either by page or by offset
|
14
|
+
strapi_server_status: There is an error from the Strapi server with status
|
15
|
+
faraday_connection: There is an error while implementing connection with Faraday
|
16
|
+
configuration: You must configure StrapiRuby before using it. See README.md for details.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "colorize"
|
2
|
+
|
3
|
+
module StrapiRuby
|
4
|
+
class << self
|
5
|
+
attr_writer :logger
|
6
|
+
|
7
|
+
def logger
|
8
|
+
@logger ||= Logger.new($stdout).tap do |log|
|
9
|
+
log.progname = name
|
10
|
+
log.formatter = proc do |severity, datetime, progname, msg|
|
11
|
+
case severity
|
12
|
+
when "ERROR"
|
13
|
+
"[#{datetime.strftime("%Y-%m-%d %H:%M:%S")}] #{progname} - #{severity}: #{msg}".red
|
14
|
+
else
|
15
|
+
"[#{datetime.strftime("%Y-%m-%d %H:%M:%S")}] #{progname} - #{severity}: #{msg}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/strapi_ruby/version.rb
CHANGED
data/lib/strapi_ruby.rb
CHANGED
@@ -13,6 +13,7 @@ require_relative "strapi_ruby/configuration"
|
|
13
13
|
require_relative "strapi_ruby/config"
|
14
14
|
|
15
15
|
# Load errors
|
16
|
+
require_relative "strapi_ruby/errors/logger"
|
16
17
|
require_relative "strapi_ruby/errors/client_error"
|
17
18
|
require_relative "strapi_ruby/errors/configuration_error"
|
18
19
|
require_relative "strapi_ruby/errors/error_message"
|
@@ -24,4 +25,3 @@ module StrapiRuby
|
|
24
25
|
extend Configuration
|
25
26
|
extend Interface
|
26
27
|
end
|
27
|
-
|
Binary file
|
data/strapi_ruby.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strapi_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxence Robinet
|
@@ -10,6 +10,20 @@ bindir: exe
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2023-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: faraday
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,6 +110,7 @@ files:
|
|
96
110
|
- lib/strapi_ruby/errors/error_code.yml
|
97
111
|
- lib/strapi_ruby/errors/error_message.rb
|
98
112
|
- lib/strapi_ruby/errors/error_text.yml
|
113
|
+
- lib/strapi_ruby/errors/logger.rb
|
99
114
|
- lib/strapi_ruby/formatter.rb
|
100
115
|
- lib/strapi_ruby/interface.rb
|
101
116
|
- lib/strapi_ruby/markdown.rb
|
@@ -105,6 +120,7 @@ files:
|
|
105
120
|
- lib/strapi_ruby/version.rb
|
106
121
|
- rubocop.txt
|
107
122
|
- sig/strapi_ruby.rbs
|
123
|
+
- strapi_ruby-0.1.0.gem
|
108
124
|
- strapi_ruby.gemspec
|
109
125
|
homepage: https://github.com/saint-james-fr/strapi_ruby
|
110
126
|
licenses:
|