Skip to content

Commit

Permalink
[Clean]: Validation Error Catching should be in Validator Visitor
Browse files Browse the repository at this point in the history
For some reason, it was implemented in MAVisitor, even thought it doesn't apply to any other subclass
  • Loading branch information
seandenigris committed Feb 29, 2024
1 parent 192ecbc commit d418ca8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
19 changes: 17 additions & 2 deletions source/Magritte-Model/MAValidatorVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,24 @@ MAValidatorVisitor >> validate: anObject using: aDescription [
MAValidatorVisitor >> visit: aDescription [
"Only visit objects that are visible and that can be changed."

| errors |
(aDescription isVisible and: [ aDescription isReadOnly not ])
ifTrue: [ super visit: aDescription ].

ifFalse: [ ^ self ].

errors := OrderedCollection new.
[
super visit: aDescription
]
on: MAValidationError
do: [ :err |
errors add: err.
err resume ].

errors isEmpty ifFalse: [
MAMultipleErrors
description: aDescription
errors: errors
signal: aDescription label ]
]

{ #category : #'visiting-descriptions' }
Expand Down
17 changes: 2 additions & 15 deletions source/Magritte-Model/MAVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,8 @@ MAVisitor class >> buildVisitorHierarchyForClass: aClass selector: aBlock classi
{ #category : #visiting }
MAVisitor >> visit: anObject [
"Visit ==anObject== with the receiving visitor."
| errors |
errors := OrderedCollection new.
[
anObject acceptMagritte: self.
]
on: MAValidationError
do: [ :err |
errors add: err.
err resume ].

errors isEmpty ifFalse: [
MAMultipleErrors
description: anObject
errors: errors
signal: anObject label ]

anObject acceptMagritte: self.
]

{ #category : #visiting }
Expand Down

0 comments on commit d418ca8

Please sign in to comment.