standard_ledger 0.8.0 → 0.9.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: 764772bfbc5d54165460fe4bcb75c3c1c708136ac0a5c20face111aeb866298c
4
- data.tar.gz: a5f692a20fa2fc0d800249276325e8fe99e4607b34047f3c6ebaf87ab929f01d
3
+ metadata.gz: cd7ecc82e5bc8d3f7eb9a8d43cbadf1d3fa1180f42fe157081d61d182a022787
4
+ data.tar.gz: 4d35b483d9139d20aaa18affc838beb60b3e791f0ef6bd3b8d3cbdc35e2a1c15
5
5
  SHA512:
6
- metadata.gz: a4da13dc9f29813caa213aa6693d2c960a6506fabe32faf4d29b67a872b00ef0daa4d1c3efd8c77061b795c2dee253dbf9e3305a81b3b5c4ca454155450f0342
7
- data.tar.gz: ce26ae4bf9b159ee039d997cca604fb01a4b87f96ee0874f9a54bdb7167bcb898b38a11e52651b8951147d5eea55d91d210c3bff394d55b6cb31987cf6f23158
6
+ metadata.gz: be20b42b99109406f022c62fb4265e47bad5c2b5c620e94c97475c003859a6be53aa4f46c663f3b518dfb957cf9249638e275eaf4a5278ffad0d01025fd30091
7
+ data.tar.gz: '0634709547f626bf6ef39ebeb0b6032254fc1093035dcd57f7fcc994a5ba7a06d339413dd77aa29b26a84b28f424b1cee410f678ef3ea5f1077563ead09bfa42'
data/CHANGELOG.md CHANGED
@@ -6,6 +6,20 @@ project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.9.0] - 2026-11-23
10
+
11
+ ### Added
12
+
13
+ - **`Config#error_reporter`**: an optional callable `(error, context)` that
14
+ receives the errors the gem reports (a failed `refresh!`, re-raised after
15
+ reporting, and a failing `concurrently: :auto` catalog probe, handled). The
16
+ context is the site's Hash (`view:`, plus `concurrently:` for a failed
17
+ refresh) merged with `source: "standard_ledger"`, `handled:` and `severity:`.
18
+ nil (the default) keeps the existing `Rails.error.report` /
19
+ `ActiveSupport.error_reporter` behaviour unchanged. Both sites already went
20
+ through `StandardLedger.report_error`, which now checks the setting first.
21
+ A raising reporter is still swallowed and never masks the original error.
22
+
9
23
  ## [0.8.0] - 2026-10-28
10
24
 
11
25
  ### Fixed
data/README.md CHANGED
@@ -140,6 +140,21 @@ failure is reported once. Input errors (an invalid view name, an unknown
140
140
  and are not reported by the gem. View names must be bare or `schema.view`
141
141
  identifiers. Anything else raises `ArgumentError`.
142
142
 
143
+ Both reports go to `Config#error_reporter` instead when it is set, a callable
144
+ taking `(error, context)`. The context is the site's Hash merged with
145
+ `source: "standard_ledger"`, `handled:` and `severity:`, so the reporter can
146
+ tell the re-raised refresh failure from the handled probe failure:
147
+
148
+ ```ruby
149
+ StandardLedger.configure do |c|
150
+ c.error_reporter = ->(error, context) { Sentry.capture_exception(error, extra: context) }
151
+ end
152
+ ```
153
+
154
+ It replaces the `Rails.error` call. Rails' dedupe does not apply to a custom
155
+ reporter, so keep no report-and-re-raise rescue of your own around `refresh!`.
156
+ A reporter that raises is swallowed and never masks the original error.
157
+
143
158
  ## Installation
144
159
 
145
160
  ```ruby
@@ -32,6 +32,15 @@ StandardLedger.configure do |c|
32
32
  # <prefix>.projection.failed
33
33
  # c.notification_namespace = "standard_ledger"
34
34
 
35
+ # ---------------------------------------------------------------------------
36
+ # Error reporting
37
+ # ---------------------------------------------------------------------------
38
+
39
+ # Where a failed refresh! (re-raised) and a failing :auto catalog probe
40
+ # (handled) are reported. Default nil: Rails.error.report. The context Hash
41
+ # carries the site's keys plus source:, handled: and severity:.
42
+ # c.error_reporter = ->(error, context) { Sentry.capture_exception(error, extra: context) }
43
+
35
44
  # ---------------------------------------------------------------------------
36
45
  # Host Result interop
37
46
  # ---------------------------------------------------------------------------
@@ -32,11 +32,32 @@ module StandardLedger
32
32
  # `<prefix>.projection.failed`.
33
33
  attr_accessor :notification_namespace
34
34
 
35
+ # Optional: where the gem sends the errors it reports — a failed
36
+ # `refresh!` (re-raised after reporting) and a failing `:auto` catalog
37
+ # probe (handled; the refresh runs plain). A callable taking
38
+ # `(error, context)`. `context` is the site's Hash (`view:`, plus
39
+ # `concurrently:` for a failed refresh) merged with
40
+ # `source: "standard_ledger"`, `handled:` and `severity:`, so a reporter
41
+ # can tell the re-raised refresh error from the handled probe failure.
42
+ #
43
+ # nil (the default) means `Rails.error.report` (or
44
+ # `ActiveSupport.error_reporter` outside Rails) with `handled:`,
45
+ # `severity:` and `source: "standard_ledger"` as keywords:
46
+ #
47
+ # c.error_reporter = ->(error, context) { Sentry.capture_exception(error, extra: context) }
48
+ #
49
+ # It replaces the Rails.error call. Rails.error's dedupe (it skips an
50
+ # exception it has already reported) does not apply to a custom reporter,
51
+ # so a host that also reports the re-raised refresh error sees it twice.
52
+ # A reporter that raises is swallowed and never masks the original error.
53
+ attr_accessor :error_reporter
54
+
35
55
  def initialize
36
56
  @matview_refresh_strategy = :concurrent
37
57
  @result_class = nil
38
58
  @result_adapter = nil
39
59
  @notification_namespace = "standard_ledger"
60
+ @error_reporter = nil
40
61
  end
41
62
 
42
63
  # True when the host has wired up its own Result type. When false, the gem
@@ -1,3 +1,3 @@
1
1
  module StandardLedger
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -137,12 +137,18 @@ module StandardLedger
137
137
  )
138
138
  end
139
139
 
140
- # Report +error+ through `Rails.error` (or `ActiveSupport.error_reporter`
141
- # outside Rails) with `source: "standard_ledger"`. A reporter failure is
142
- # swallowed so it can never mask the error being reported.
140
+ # Report +error+ through `Config#error_reporter` when set, otherwise
141
+ # `Rails.error` (or `ActiveSupport.error_reporter` outside Rails) with
142
+ # `source: "standard_ledger"`. A reporter failure is swallowed so it can
143
+ # never mask the error being reported.
143
144
  #
144
145
  # @api private
145
146
  def report_error(error, handled:, severity:, context:)
147
+ if (custom = config.error_reporter)
148
+ custom.call(error, { **context, source: "standard_ledger", handled: handled, severity: severity })
149
+ return
150
+ end
151
+
146
152
  reporter =
147
153
  if defined?(::Rails) && ::Rails.respond_to?(:error)
148
154
  ::Rails.error
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard_ledger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
- - Jaryl Sim
7
+ - Rarebit One
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 4.0.10
146
+ rubygems_version: 4.0.20
147
147
  specification_version: 4
148
148
  summary: Immutable, append-only journal entries and materialized-view refresh for
149
149
  Rails apps.