From d418ca83fb1d7ec4cb24c84b6abe9edc9055fa63 Mon Sep 17 00:00:00 2001 From: Sean DeNigris Date: Wed, 28 Feb 2024 22:56:18 -0500 Subject: [PATCH] [Clean]: Validation Error Catching should be in Validator Visitor For some reason, it was implemented in MAVisitor, even thought it doesn't apply to any other subclass --- .../MAValidatorVisitor.class.st | 19 +++++++++++++++++-- source/Magritte-Model/MAVisitor.class.st | 17 ++--------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/source/Magritte-Model/MAValidatorVisitor.class.st b/source/Magritte-Model/MAValidatorVisitor.class.st index a4b5afa3..d9b10ac8 100644 --- a/source/Magritte-Model/MAValidatorVisitor.class.st +++ b/source/Magritte-Model/MAValidatorVisitor.class.st @@ -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' } diff --git a/source/Magritte-Model/MAVisitor.class.st b/source/Magritte-Model/MAVisitor.class.st index c599a65e..06d2da42 100644 --- a/source/Magritte-Model/MAVisitor.class.st +++ b/source/Magritte-Model/MAVisitor.class.st @@ -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 }