diff --git a/rowan/components/Deployment.ston b/rowan/components/Deployment.ston index 729b3b9..6d8e99b 100644 --- a/rowan/components/Deployment.ston +++ b/rowan/components/Deployment.ston @@ -12,6 +12,7 @@ RwSimpleProjectLoadComponentV2 { 'Buoy-Conditions', 'Buoy-Conditions-Extensions', 'Buoy-Dynamic-Binding', + 'Buoy-Exception-Handling-Extensions', 'Buoy-Math-GS64-Extensions', 'Buoy-Metaprogramming', 'Buoy-Metaprogramming-Extensions', @@ -29,13 +30,16 @@ RwSimpleProjectLoadComponentV2 { }, 'Buoy-Collections-GS64-Extensions' : { 'symbolDictName' : 'Globals' - }, + }, 'Buoy-Comparison-Extensions' : { 'symbolDictName' : 'Globals' }, 'Buoy-Conditions-Extensions' : { 'symbolDictName' : 'Globals' }, + 'Buoy-Exception-Handling-Extensions' : { + 'symbolDictName' : 'Globals' + }, 'Buoy-Math-GS64-Extensions' : { 'symbolDictName' : 'Globals' }, diff --git a/rowan/components/Tests.ston b/rowan/components/Tests.ston index fa759b2..f6307d9 100644 --- a/rowan/components/Tests.ston +++ b/rowan/components/Tests.ston @@ -11,6 +11,7 @@ RwSimpleProjectLoadComponentV2 { 'Buoy-Comparison-Tests', 'Buoy-Conditions-Tests', 'Buoy-Dynamic-Binding-Tests', + 'Buoy-Exception-Handling-Tests', 'Buoy-Metaprogramming-Tests', 'Buoy-SUnit-Tests' ], diff --git a/source/BaselineOfBuoy/BaselineOfBuoy.class.st b/source/BaselineOfBuoy/BaselineOfBuoy.class.st index ac69e60..d8b0788 100644 --- a/source/BaselineOfBuoy/BaselineOfBuoy.class.st +++ b/source/BaselineOfBuoy/BaselineOfBuoy.class.st @@ -115,9 +115,9 @@ BaselineOfBuoy >> baselineDynamicBinding: spec [ BaselineOfBuoy >> baselineExceptionHandling: spec [ spec - package: 'Buoy-Exception-Handling'; - group: 'Deployment' with: 'Buoy-Exception-Handling'; - package: 'Buoy-Exception-Handling-Tests' with: [ spec requires: 'Buoy-Exception-Handling' ]; + package: 'Buoy-Exception-Handling-Extensions'; + group: 'Deployment' with: 'Buoy-Exception-Handling-Extensions'; + package: 'Buoy-Exception-Handling-Tests' with: [ spec requires: 'Buoy-Exception-Handling-Extensions' ]; group: 'Tests' with: 'Buoy-Exception-Handling-Tests' ] diff --git a/source/Buoy-Exception-Handling-Extensions/BlockClosure.extension.st b/source/Buoy-Exception-Handling-Extensions/BlockClosure.extension.st new file mode 100644 index 0000000..3b23655 --- /dev/null +++ b/source/Buoy-Exception-Handling-Extensions/BlockClosure.extension.st @@ -0,0 +1,12 @@ +Extension { #name : #BlockClosure } + +{ #category : #'*Buoy-Exception-Handling-Extensions' } +BlockClosure >> on: selector except: exclusionSelector do: action [ + + ^ self + on: selector + do: [ :exception | + (exclusionSelector handles: exception) + ifTrue: [ exception pass ] + ifFalse: [ action value: exception ] ] +] diff --git a/source/Buoy-Exception-Handling-Extensions/package.st b/source/Buoy-Exception-Handling-Extensions/package.st new file mode 100644 index 0000000..6c8ffa1 --- /dev/null +++ b/source/Buoy-Exception-Handling-Extensions/package.st @@ -0,0 +1 @@ +Package { #name : #'Buoy-Exception-Handling-Extensions' } diff --git a/source/Buoy-Exception-Handling-Tests/ExceptionHandlingSystemTest.class.st b/source/Buoy-Exception-Handling-Tests/ExceptionHandlingSystemTest.class.st index 7e569dd..371f46d 100644 --- a/source/Buoy-Exception-Handling-Tests/ExceptionHandlingSystemTest.class.st +++ b/source/Buoy-Exception-Handling-Tests/ExceptionHandlingSystemTest.class.st @@ -32,25 +32,27 @@ ExceptionHandlingSystemTest >> handleZeroDivideAndReturnWithCaret [ { #category : #'tests - exception sets' } ExceptionHandlingSystemTest >> testCatchingSetsOfExceptions [ - | result | - - result := [ ZeroDivide signal + Warning signal ] - on: Warning , ZeroDivide - do: [ :ex | ex resume: 1 ]. - - self assert: result equals: 2 + self assert: ([ + Warning signal. + false ] + on: Warning , ZeroDivide + do: [ :ex | ex return: true ]). + + self assert: ([ + ZeroDivide signal. + false ] + on: Warning , ZeroDivide + do: [ :ex | ex return: true ]) ] { #category : #'tests - exception sets' } ExceptionHandlingSystemTest >> testCatchingSetsOfExceptionsWithHierarchy [ - | result | - - result := [ ZeroDivide signal + Warning signal ] - on: Notification , Error - do: [ :ex | ex resume: 1 ]. - - self assert: result equals: 2 + self assert: ([ + Warning signal. + false ] + on: Notification , Error + do: [ :ex | ex return: true ]) ] { #category : #'tests - ensure' } @@ -85,19 +87,13 @@ ExceptionHandlingSystemTest >> testEnsureSemanticsWhenNoException [ { #category : #'tests - exception sets' } ExceptionHandlingSystemTest >> testExceptionSetsConcatenation [ - | result | - - result := [ ZeroDivide signal + Warning signal ] - on: Warning , ZeroDivide , ( MessageNotUnderstood , Error ) - do: [ :ex | ex resume: 1 ]. - - self assert: result equals: 2. - - result := [ ZeroDivide signal + Warning signal ] - on: MessageNotUnderstood , Error , ( Warning , ZeroDivide ) - do: [ :ex | ex resume: 1 ]. + self assert: ([ ZeroDivide signal ] + on: Warning , ZeroDivide , (MessageNotUnderstood , Error) + do: [ :ex | ex return: true ]). - self assert: result equals: 2 + self assert: ([ Object new perform: #asdf ] + on: MessageNotUnderstood , Error , (Warning , ZeroDivide) + do: [ :ex | ex return: true ]) ] { #category : #'tests - exception sets' } diff --git a/source/Buoy-Exception-Handling/BlockClosure.extension.st b/source/Buoy-Exception-Handling/BlockClosure.extension.st deleted file mode 100644 index bb54693..0000000 --- a/source/Buoy-Exception-Handling/BlockClosure.extension.st +++ /dev/null @@ -1,9 +0,0 @@ -Extension { #name : #BlockClosure } - -{ #category : #'*Buoy-Exception-Handling' } -BlockClosure >> on: selector except: exclusionSelector do: action [ - - ^ self - on: selector - exclusionSelector - do: action -] diff --git a/source/Buoy-Exception-Handling/package.st b/source/Buoy-Exception-Handling/package.st deleted file mode 100644 index 98068da..0000000 --- a/source/Buoy-Exception-Handling/package.st +++ /dev/null @@ -1 +0,0 @@ -Package { #name : #'Buoy-Exception-Handling' }