Exception: PgEventstore::WrongExpectedRevisionError
- Defined in:
- lib/pg_eventstore/errors.rb,
sig/pg_eventstore/errors.rbs
Instance Attribute Summary collapse
-
#expected_revision ⇒ Integer, Symbol
Returns the value of attribute expected_revision.
-
#revision ⇒ Integer
Returns the value of attribute revision.
-
#stream ⇒ Stream
Returns the value of attribute stream.
-
#verdict ⇒ Symbol
Returns the value of attribute verdict.
Instance Method Summary collapse
- #current_no_stream ⇒ String
- #expected_no_stream ⇒ String
- #expected_stream_exists ⇒ String
-
#initialize(revision:, expected_revision:, stream:, verdict:) ⇒ WrongExpectedRevisionError
constructor
A new instance of WrongExpectedRevisionError.
- #stream_descr ⇒ String
- #unmatched_stream_revision ⇒ String
- #user_friendly_message ⇒ String
Methods inherited from Error
Constructor Details
#initialize(revision:, expected_revision:, stream:, verdict:) ⇒ WrongExpectedRevisionError
Returns a new instance of WrongExpectedRevisionError.
66 67 68 69 70 71 72 |
# File 'lib/pg_eventstore/errors.rb', line 66 def initialize(revision:, expected_revision:, stream:, verdict:) @revision = revision @expected_revision = expected_revision @stream = stream @verdict = verdict super() end |
Instance Attribute Details
#expected_revision ⇒ Integer, Symbol
Returns the value of attribute expected_revision.
57 58 59 |
# File 'lib/pg_eventstore/errors.rb', line 57 def expected_revision @expected_revision end |
#revision ⇒ Integer
Returns the value of attribute revision.
54 55 56 |
# File 'lib/pg_eventstore/errors.rb', line 54 def revision @revision end |
#stream ⇒ Stream
Returns the value of attribute stream.
51 52 53 |
# File 'lib/pg_eventstore/errors.rb', line 51 def stream @stream end |
#verdict ⇒ Symbol
Returns the value of attribute verdict.
60 61 62 |
# File 'lib/pg_eventstore/errors.rb', line 60 def verdict @verdict end |
Instance Method Details
#current_no_stream ⇒ String
103 104 105 |
# File 'lib/pg_eventstore/errors.rb', line 103 def current_no_stream "#{stream_descr} stream revision #{expected_revision.inspect} is expected, but stream does not exist." end |
#expected_no_stream ⇒ String
98 99 100 |
# File 'lib/pg_eventstore/errors.rb', line 98 def expected_no_stream "Expected stream #{stream_descr} to be absent, but it actually exists." end |
#expected_stream_exists ⇒ String
93 94 95 |
# File 'lib/pg_eventstore/errors.rb', line 93 def expected_stream_exists "Expected stream #{stream_descr} to exist, but it doesn't." end |
#stream_descr ⇒ String
116 117 118 |
# File 'lib/pg_eventstore/errors.rb', line 116 def stream_descr stream.to_hash.inspect end |
#unmatched_stream_revision ⇒ String
108 109 110 111 112 113 |
# File 'lib/pg_eventstore/errors.rb', line 108 def unmatched_stream_revision <<~TEXT.strip #{stream_descr} stream revision #{expected_revision.inspect} is expected, but actual stream revision is \ #{revision.inspect}. TEXT end |
#user_friendly_message ⇒ String
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/pg_eventstore/errors.rb', line 77 def case verdict when :expected_to_have_stream_with_given_revision current_no_stream when :unmatched_stream_revision unmatched_stream_revision when :expected_to_have_stream expected_stream_exists when :expected_not_to_have_stream expected_no_stream else Utils.missing_implementation!(verdict) end end |