help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Re: Magritte-Seaside and validation errors


From: Paolo Bonzini
Subject: [Help-smalltalk] Re: Magritte-Seaside and validation errors
Date: Tue, 05 May 2009 11:54:45 +0200
User-agent: Thunderbird 2.0.0.21 (Macintosh/20090302)

Lukas Renggli wrote:
> Cool test ;-)
> 
> I get  #(false false false true false false false true) in Pharo
> #10126 (that's an old version).
> 
> The validation code is really ugly. It started out simple, but then
> got incredibly complicated and fragile over time. I already fixed many
> bugs that appeared in edge cases. Maybe we should instead just try to
> fix Magritte instead?

Cool test, but I was off track. :-)  The case that is hit by Magritte is
the #ifFalse: one: the exception is created non-resumable, and made
resumable and resignaled within the handler.  Now, if I understand
correctly the ugliness is there to allow restarting to the test for
another field, but at the same time avoiding an MARequiredError and an
MAKindError for the same field.

Thus, I took Nico's description and modified to use, instead of required
MAStringDescriptions, a pair of required integer MANumberDescription.
Then, just using this simpler code seems to work as I cannot get it to
emit more than two errors:

diff --git a/packages/magritte/magritte-model.st
b/packages/magritte/magritte-model.st
index 0f05d99..0c93469 100644
--- a/packages/magritte/magritte-model.st
+++ b/packages/magritte/magritte-model.st
@@ -5507,13 +5507,9 @@ MAValidatorVisitor>>#visitDescription:
        <category: 'visiting-descriptions'>
        [self validate: self object using: aDescription] on:
MAValidationError
            do:
-               [:err |
-               err isResumable
-                   ifTrue: [err pass]
-                   ifFalse:
-                       [err
-                           beResumable;
-                           signal]]
+               [:err |
+               err isResumable ifFalse: [err beResumable].
+               err pass]
     ]

     visitTableDescription: aDescription [

and all the unit tests still pass.  I'm a bit puzzled, maybe you were
working around some issue in Squeak or maybe GNU Smalltalk has a bug?

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]