rggen-core 0.22.0 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/rggen +2 -2
- data/lib/rggen/core/exceptions.rb +6 -4
- data/lib/rggen/core/options.rb +6 -0
- data/lib/rggen/core/utility/error_utility.rb +33 -6
- data/lib/rggen/core/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bb706524df1f6ce830d322807a5fefe011d196b047b6a21305aedd2d139e44f
|
4
|
+
data.tar.gz: b5e0f96144161ca175d50fca3efa30a87c6a2024eb0a44e2990712a295b258d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f08a781cf05602cb6d5412f3c6b72789de4b601acf0054458476bd49366757daa7ae4057d89c2d30b87d6efe54be4faf0def357b9ffa8d4a7af513f28b754c3
|
7
|
+
data.tar.gz: 15952384793891091f3cc415a0770027a47d394867b5a8bef6690424e0ccd7a21ddef9af420ea2e9817f748ff8a764af5695de39e80de823c085546a4232d8b9
|
data/exe/rggen
CHANGED
@@ -8,6 +8,6 @@ begin
|
|
8
8
|
cli = RgGen::Core::CLI.new
|
9
9
|
cli.run(ARGV)
|
10
10
|
rescue ScriptError, StandardError => e
|
11
|
-
|
12
|
-
|
11
|
+
options = [cli.options[:print_verbose_info], cli.options[:print_backtrace]]
|
12
|
+
abort RgGen::Core::Utility::ErrorUtility.compose_error_message(e, *options)
|
13
13
|
end
|
@@ -3,17 +3,19 @@
|
|
3
3
|
module RgGen
|
4
4
|
module Core
|
5
5
|
class RgGenError < StandardError
|
6
|
-
def initialize(message,
|
6
|
+
def initialize(message, location_info = nil, verbose_info = nil)
|
7
7
|
super(message)
|
8
8
|
@error_message = message
|
9
|
-
@
|
9
|
+
@location_info = location_info
|
10
|
+
@verbose_info = verbose_info
|
10
11
|
end
|
11
12
|
|
12
13
|
attr_reader :error_message
|
13
|
-
attr_reader :
|
14
|
+
attr_reader :location_info
|
15
|
+
attr_reader :verbose_info
|
14
16
|
|
15
17
|
def to_s
|
16
|
-
|
18
|
+
location_info && "#{super} -- #{location_info}" || super
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
data/lib/rggen/core/options.rb
CHANGED
@@ -150,6 +150,12 @@ module RgGen
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
+
Options.add_option(:print_verbose_info) do |option|
|
154
|
+
option.long_option '--print-verbose-info'
|
155
|
+
option.default false
|
156
|
+
option.description 'Print verbose information when an error occurs'
|
157
|
+
end
|
158
|
+
|
153
159
|
Options.add_option(:print_backtrace) do |option|
|
154
160
|
option.long_option '--print-backtrace'
|
155
161
|
option.default false
|
@@ -4,14 +4,41 @@ module RgGen
|
|
4
4
|
module Core
|
5
5
|
module Utility
|
6
6
|
module ErrorUtility
|
7
|
-
|
7
|
+
class MessageComposer
|
8
|
+
def compose(error, verbose, backtrace)
|
9
|
+
lines = []
|
10
|
+
add_basic_info(error, lines)
|
11
|
+
add_verbose_info(error, lines) if verbose
|
12
|
+
add_backtrace(error, lines) if backtrace
|
13
|
+
lines.join("\n")
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def add_basic_info(error, lines)
|
19
|
+
lines << "[#{error.class.lastname}] #{error}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_verbose_info(error, lines)
|
23
|
+
return unless error.respond_to?(:verbose_info)
|
24
|
+
return unless error.verbose_info
|
25
|
+
|
26
|
+
lines << 'verbose information:'
|
27
|
+
error
|
28
|
+
.verbose_info.lines(chomp: true)
|
29
|
+
.each { |info| lines << " #{info}" }
|
30
|
+
end
|
8
31
|
|
9
|
-
|
10
|
-
|
11
|
-
lines << "[#{error.class.lastname}] #{error.message}"
|
12
|
-
verbose &&
|
32
|
+
def add_backtrace(error, lines)
|
33
|
+
lines << 'backtrace:'
|
13
34
|
error.backtrace.each { |trace| lines << " #{trace}" }
|
14
|
-
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module_function
|
39
|
+
|
40
|
+
def compose_error_message(error, verbose, backtrace)
|
41
|
+
MessageComposer.new.compose(error, verbose, backtrace)
|
15
42
|
end
|
16
43
|
end
|
17
44
|
end
|
data/lib/rggen/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rggen-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taichi Ishitani
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docile
|
@@ -189,5 +189,5 @@ requirements: []
|
|
189
189
|
rubygems_version: 3.1.2
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
|
-
summary: rggen-core-0.
|
192
|
+
summary: rggen-core-0.23.0
|
193
193
|
test_files: []
|