[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[S8ObjC] nsError

SwikiCodeRobot @> #testS8ObjCNsError

"Test NSError (accessing a missing file)"
| err errRef str domain userInfo |
errRef := (S8ObjC alloc: (ObjCClass named: #NSError)) ref.
str := (ObjCClass named: #NSString) handle valueWithArguments: #(
	stringWithContentsOfFile 'a path to a file that do not exist'
	encoding 0
	error ),(Array with: errRef) json.
str notNil ifTrue: [ self error: 'Result must be nil' ].
err := errRef deref.
err isNil ifTrue: [ self error: 'err must be a NSError' ].
self print: 'err=' ,err.
domain := err value: #domain.
userInfo := err value: #userInfo.
self print: ' Domain=',domain.
self print: ' Ok - File not found ' ,(userInfo value: #objectForKey value: (S8ObjC value: #NSFilePath)) printString.
#ok