Skip to content

Commit

Permalink
Fixes #3430
Browse files Browse the repository at this point in the history
ifError: block accepts anError instance as a first argument
  • Loading branch information
kamk committed Jan 11, 2020
1 parent 89202f8 commit ded582f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/EmergencyEvaluator/Transcripter.class.st
Expand Up @@ -228,7 +228,7 @@ Transcripter >> readEvalPrint [
ifFalse: [self cr; show: 'Only one level of revert currently supported']]
ifFalse: [self cr;
show: ([self class compiler evaluate: line]
ifError: [:err | err])]].
ifError: [:err | err description])]].
self cr; show: 'Done'.

]
Expand Down
15 changes: 7 additions & 8 deletions src/Kernel-Tests/BlockClosureTest.class.st
Expand Up @@ -143,12 +143,11 @@ BlockClosureTest >> testCullCullCullCull [
BlockClosureTest >> testNew [
self should: [Context new: 5] raise: Error.
[Context new: 5]
ifError: [:error | error = 'Error: Contexts must only be created with newForMethod:'].
ifError: [:error | self assert: error description equals: 'Error: Contexts must only be created with newForMethod:'].
[Context new]
ifError: [:error | error = 'Error: Contexts must only be created with newForMethod:'].
ifError: [:error | self assert: error description equals: 'Error: Contexts must only be created with newForMethod:'].
[Context basicNew]
ifError: [:error | error = 'Error: Contexts must only be created with newForMethod:'].

ifError: [:error | self assert: error description equals: 'Error: Contexts must only be created with newForMethod:'].

]

Expand All @@ -158,8 +157,8 @@ BlockClosureTest >> testNoArguments [
"avoid compile error in GemStone"
block1 := [ :arg | 1 + 2 ].
block2 := [ :arg1 :arg2 | 1 + 2 ].
[ 10 timesRepeat: block1 ] ifError: [ :err | self deny: err equals: 'This block requires 1 arguments.' ].
[ 10 timesRepeat: block2 ] ifError: [ :err | self deny: err equals: 'This block requires 2 arguments.' ]
[ 10 timesRepeat: block1 ] ifError: [ :err | self assert: err description equals: 'ArgumentsCountMismatch: This block accepts 1 argument, but was called with 0 arguments.' ].
[ 10 timesRepeat: block2 ] ifError: [ :err | self assert: err description equals: 'ArgumentsCountMismatch: This block accepts 2 arguments, but was called with 0 arguments.' ]
]

{ #category : #'tests - on-fork' }
Expand Down Expand Up @@ -271,8 +270,8 @@ BlockClosureTest >> testOneArgument [
| c |
c := OrderedCollection new.
c add: 'hello'.
[ c do: [ 1 + 2 ] ] ifError: [ :err | self deny: err equals: 'This block requires 0 arguments.' ].
[ c do: [ :arg1 :arg2 | 1 + 2 ] ] ifError: [ :err | self deny: err equals: 'This block requires 2 arguments.' ]
[ c do: [ 1 + 2 ] ] ifError: [ :err | self assert: err description equals: 'ArgumentsCountMismatch: This block accepts 0 arguments, but was called with 1 argument.' ].
[ c do: [ :arg1 :arg2 | 1 + 2 ] ] ifError: [ :err | self assert: err description equals: 'ArgumentsCountMismatch: This block accepts 2 arguments, but was called with 1 argument.' ]
]

{ #category : #'tests - printing' }
Expand Down
4 changes: 2 additions & 2 deletions src/Kernel/BlockClosure.class.st
Expand Up @@ -336,13 +336,13 @@ BlockClosure >> ifError: errorHandlerBlock [
"Examples:
[1 whatsUpDoc] ifError: [:err :rcvr | 'huh?'].
[1 / 0] ifError: [:err :rcvr |
'ZeroDivide' = err
ZeroDivide = err class
ifTrue: [Float infinity]
ifFalse: [self error: err]]
"

^ self on: Error do: [:ex |
errorHandlerBlock cull: ex description cull: ex receiver]
errorHandlerBlock cull: ex cull: ex receiver]
]

{ #category : #accessing }
Expand Down
4 changes: 2 additions & 2 deletions src/Kernel/Semaphore.class.st
Expand Up @@ -87,9 +87,9 @@ Semaphore >> critical: mutuallyExcludedBlock ifError: errorBlock [
| blockValue hasError errMsg errRcvr |
hasError := false.
self critical:[
blockValue := mutuallyExcludedBlock ifError: [ :msg :rcvr|
blockValue := mutuallyExcludedBlock ifError: [ :err :rcvr|
hasError := true.
errMsg := msg.
errMsg := err description.
errRcvr := rcvr
].
].
Expand Down
2 changes: 1 addition & 1 deletion src/Morphic-Core/WorldState.class.st
Expand Up @@ -473,7 +473,7 @@ WorldState >> displayWorldSafely: aWorld [
[errCtx notNil and:[(errCtx receiver isMorph) not]]
whileTrue:[errCtx := errCtx sender].
"If we're at the root of the context chain then we have a fatal drawing problem"
errCtx ifNil:[^self handleFatalDrawingError: err].
errCtx ifNil:[^self handleFatalDrawingError: err description].
errMorph := errCtx receiver.
"If the morph causing the problem has already the #drawError flag set,
then search for the next morph above in the caller chain."
Expand Down
2 changes: 1 addition & 1 deletion src/Tool-Finder/MethodFinderSend.class.st
Expand Up @@ -74,7 +74,7 @@ MethodFinderSend >> resultIn: expectedResult [
"comment stating purpose of message"

[ [ ^ expectedResult = (receiver perform: selector withArguments: arguments) ]
ifError: [ :aString :aReceiver | ^ false ] ]
ifError: [ :anError :aReceiver | ^ false ] ]
on: Deprecation
do: [ :depr | ^ false ]
]
Expand Down

0 comments on commit ded582f

Please sign in to comment.