foobara 0.0.25 → 0.0.26

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: 0526c0ae0c3728d7286fc90703fbf82192784b3b0b80379aafa5dfe142e48d36
4
- data.tar.gz: 6d1b3840a0a1f94a763e844a0230d90715e4aa0f3fffb16abce6bc9837e08e18
3
+ metadata.gz: 74ed1cc03610fe5533258dc181f0874db18119716a193820aa3b227c4c70646f
4
+ data.tar.gz: 30f4d98511c5842e55b66a184952b19514dab9a18b0a86d14c4a708becaa758f
5
5
  SHA512:
6
- metadata.gz: 2bff7c76cfa36de8d054ef114f9b80f7bde028f7195fb496f793e374f7455e7adcb8e715f6b02f0f2aea047b8e9c1524975017a1fefbead0c59dcad7dc1c3206
7
- data.tar.gz: b63d6ec995d9139e7ab86209f9f05d527609ab0f95e0d951dac753cfb9a50f35eac48b17c171e3880d50448ec2dcb0979b9c352a66162bfb8295ae99fe6f561d
6
+ metadata.gz: 8d4fc1f0de283351f4aeefbf8467c3fe77a66122e7621db77a086578ee4958cf0402ef158781ca1790326ad94d8dd1f8f5ff1f773ce3e6f1b3d393ef9313a0bc
7
+ data.tar.gz: c79c5217ae9463cf8139d065165f5c7e3508eedbd21a468c4d3e9059f49754c16fde5352cbd2f4a6ad55faa6a7a866a1db6e436dc24820831da14e431c0edbb1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
- ## [0.0.25] - 2024-12-03
1
+ ## [0.0.26] - 2024-12-03
2
2
 
3
+ - Add error defaults for message and context
4
+ - Support registering possible runtime errors by symbol
3
5
  - Make sure errors created via Command.possible_*error are namespaced to that command
4
6
  - Allow passing all Error subclass parameters into possible_*error calls
5
7
  - Allow creating entity types from declaration without model_module
@@ -35,6 +35,9 @@ module Foobara
35
35
  # :nocov:
36
36
  elsif arg.is_a?(::Class) && arg < Foobara::Error
37
37
  PossibleError.new(arg)
38
+ elsif arg.is_a?(::Symbol)
39
+ error_class = Foobara::RuntimeError.subclass(mod: self, symbol: arg)
40
+ PossibleError.new(error_class, symbol: arg)
38
41
  else
39
42
  # :nocov:
40
43
  raise ArgumentError, "Expected a PossibleError or an Error but got #{arg}"
@@ -26,10 +26,6 @@ module Foobara
26
26
  def context_type_declaration
27
27
  {}
28
28
  end
29
-
30
- def context
31
- {}
32
- end
33
29
  end
34
30
  end
35
31
 
@@ -36,7 +36,7 @@ module Foobara
36
36
  end
37
37
 
38
38
  def message
39
- nil
39
+ Util.humanize(symbol.to_s)
40
40
  end
41
41
 
42
42
  def context
@@ -16,7 +16,7 @@ module Foobara
16
16
  end
17
17
 
18
18
  # TODO: why path instead of runtime path?
19
- def initialize(message: nil, symbol: nil, context: nil, path: nil)
19
+ def initialize(message: nil, symbol: nil, context: {}, path: nil)
20
20
  args = { message:, symbol:, context:, path: }.compact
21
21
  super(**args.merge(category: self.class.category))
22
22
  end
@@ -7,7 +7,7 @@ module Foobara
7
7
  end
8
8
  end
9
9
 
10
- def initialize(message: nil, symbol: nil, context: nil, path: nil)
10
+ def initialize(message: nil, symbol: nil, context: {}, path: nil)
11
11
  args = { message:, symbol:, context:, path: }.compact
12
12
  super(**args.merge(category: self.class.category))
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.25
4
+ version: 0.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi