rggen-core 0.22.0 → 0.23.0

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: d6fde36c04e21476aef2a09a20a3d22467bf6f4a28fa4f831c7aa7208bdb0a9a
4
- data.tar.gz: 0735722aae6a60569505b06ec3c3c9465c47f201138056752a00cc29b780d5a0
3
+ metadata.gz: 7bb706524df1f6ce830d322807a5fefe011d196b047b6a21305aedd2d139e44f
4
+ data.tar.gz: b5e0f96144161ca175d50fca3efa30a87c6a2024eb0a44e2990712a295b258d9
5
5
  SHA512:
6
- metadata.gz: 4f1ae60ad3e557b0f18514cb803c635134f93f922deae475db97745571b0ff38a0ce7571c2cef324ed1ac4250fc2e3e5d78d9d48689cfafe827d4ed938425684
7
- data.tar.gz: 589c74ee6817e7b5aa90595c7d358f2e2db730cf3b06af40ce737da62135680fd55df52259294501c2c43b063d67908b5cd0b1fe8d8fa06d9efdbe7ef05ff1cc
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
- abort RgGen::Core::Utility::ErrorUtility
12
- .compose_error_message(e, cli.options[:print_backtrace])
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, additional_info = nil)
6
+ def initialize(message, location_info = nil, verbose_info = nil)
7
7
  super(message)
8
8
  @error_message = message
9
- @additional_info = additional_info
9
+ @location_info = location_info
10
+ @verbose_info = verbose_info
10
11
  end
11
12
 
12
13
  attr_reader :error_message
13
- attr_reader :additional_info
14
+ attr_reader :location_info
15
+ attr_reader :verbose_info
14
16
 
15
17
  def to_s
16
- additional_info ? "#{super} -- #{additional_info}" : super
18
+ location_info && "#{super} -- #{location_info}" || super
17
19
  end
18
20
  end
19
21
 
@@ -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
- module_function
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
- def compose_error_message(error, verbose)
10
- lines = []
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
- lines.join("\n")
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
@@ -3,7 +3,7 @@
3
3
  module RgGen
4
4
  module Core
5
5
  MAJOR = 0
6
- MINOR = 22
6
+ MINOR = 23
7
7
  PATCH = 0
8
8
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
9
9
  end
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.22.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-17 00:00:00.000000000 Z
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.22.0
192
+ summary: rggen-core-0.23.0
193
193
  test_files: []