Add a cleaning of the vm/private folder in case of error (solve https://github.com/pharo-project/pharo-launcher/issues/88)
Add new exception if the executable is not found inside the folder
Minor code cleaning
RENAME
src/PharoLauncher-Download.package/PhLError.class/class/signalUrl..st
src/PharoLauncher-Download.package/PhLDownloadError.class/class/signalUrl..st
ADD
src/PharoLauncher-Download.package/PhLError.class/instance/uiAlert.st
+ui
+uiAlert
+ UIManager default
+ alert: self longDescription
+ title: self name
+ configure: [ :morph | (morph findDeeplyA: TextMorph) unlock ]
\ No newline at end of file

ADD
src/PharoLauncher-Download.package/PhLExecutableNotFoundError.class/README.md
+Error thrown when Pharo Launcher did not succeed to find a Pharo binary or executable inside a given folder.
+Probably, the folder should be deleted as the VM are only cached
\ No newline at end of file

ADD
src/PharoLauncher-Download.package/PhLExecutableNotFoundError.class/class/signalKind.inPath..st
+signalling
+signalKind: aKindOfApp inPath: aString
+ ^ self new
+ kindOfApplication: aKindOfApp;
+ path: aString;
+ signal
\ No newline at end of file

ADD
src/PharoLauncher-Download.package/PhLExecutableNotFoundError.class/instance/kindOfApplication..st
+accessing
+kindOfApplication: string
+ kindOfApplication := string
\ No newline at end of file

ADD
src/PharoLauncher-Download.package/PhLExecutableNotFoundError.class/instance/longDescription.st
+accessing
+longDescription
+ ^ 'Cannot detect Pharo ', kindOfApplication ,' in ', path, '.', String cr, 'Delete the folder and retry! It can also due to a corruption of the downloaded file...'
\ No newline at end of file

ADD
src/PharoLauncher-Download.package/PhLExecutableNotFoundError.class/instance/name.st
+accessing
+name
+ ^ 'Pharo Executable Not Found'
\ No newline at end of file

ADD
src/PharoLauncher-Download.package/PhLExecutableNotFoundError.class/instance/path..st
+accessing
+path: string
+ path := string
\ No newline at end of file

ADD
src/PharoLauncher-Download.package/PhLExecutableNotFoundError.class/properties.json
+{
+ "commentStamp" : "VincentBlondeau 4/12/2018 16:15",
+ "super" : "PhLError",
+ "category" : "PharoLauncher-Download-Exceptions",
+ "classinstvars" : [ ],
+ "pools" : [ ],
+ "classvars" : [ ],
+ "instvars" : [
+ "path",
+ "kindOfApplication"
+ ],
+ "name" : "PhLExecutableNotFoundError",
+ "type" : "normal"
+}
\ No newline at end of file

MODIFY
src/PharoLauncher-Download.package/PhLImageVersionDeterminationError.class/README.md
src/PharoLauncher-Download.package/PhLImageVersionDeterminationError.class/README.md
-Error throw when Pharo Launcher did not succeed to determine the Pharo version of the image to launch.
+Error thrown when Pharo Launcher did not succeed to determine the Pharo version of the image to launch.
Probably, the run command failed.
I hold the command run to determoine the version so that it can be reused for debugging purposes.
\ No newline at end of file

MODIFY
src/PharoLauncher-Download.package/PhLImageVersionDeterminationError.class/properties.json
src/PharoLauncher-Download.package/PhLImageVersionDeterminationError.class/properties.json
{
- "commentStamp" : "ChristopheDemarey 1/4/2018 10:59",
+ "commentStamp" : "VincentBlondeau 4/12/2018 16:13",
"super" : "PhLError",
"category" : "PharoLauncher-Download-Exceptions",
"classinstvars" : [ ],

MODIFY
src/PharoLauncher-Download.package/PhLVirtualMachine.class/instance/initializeOn..st
src/PharoLauncher-Download.package/PhLVirtualMachine.class/instance/initializeOn..st
@@ -3,19 +3,14 @@ initializeOn: aFolder
| executables |
executables := aFolder allChildrenMatching: self class executableName.
Smalltalk os isUnix
- ifTrue: [
- executables
- select: #isFile
- thenDo: [ :fileRef | self ensureIsExecutable: fileRef fullName ].
+ ifTrue: [ executables select: #isFile thenDo: [ :fileRef | self ensureIsExecutable: fileRef fullName ].
"On linux, either the VM exe is at the top level or a bash script at the top level has to be used"
executableRef := executables
detect: [ :fileRef | fileRef parent = aFolder ]
- ifNone: [ self error: 'Cannot detect Pharo executable in ' , aFolder fullName ].
+ ifNone: [ PhLExecutableNotFoundError signalKind: 'executable' inPath: aFolder fullName ].
vmBinaryRef := executables
- detect: [ :fileRef |
- fileRef binaryReadStreamDo: [ :stream | (stream next: 4) = self class elfMagicNumber ] ]
- ifNone: [ self error: 'Cannot detect Pharo VM binary in ' , aFolder fullName ] ]
- ifFalse: [ executableRef := vmBinaryRef := executables
- detect: #isFile
- ifNone: [ self error: 'Cannot detect Pharo executable in ' , aFolder fullName ] ].
- self ensureIsExecutable: executableRef fullName.
\ No newline at end of file
+ detect: [ :fileRef | fileRef binaryReadStreamDo: [ :stream | (stream next: 4) = self class elfMagicNumber ] ]
+ ifNone: [ PhLExecutableNotFoundError signalKind: 'VM binary' inPath: aFolder fullName ] ]
+ ifFalse:
+ [ executableRef := vmBinaryRef := executables detect: #isFile ifNone: [ PhLExecutableNotFoundError signalKind: 'executable' inPath: aFolder fullName ] ].
+ self ensureIsExecutable: executableRef fullName
\ No newline at end of file

MODIFY
src/PharoLauncher-Download.package/PhLVirtualMachineManager.class/instance/availableVirtualMachinesOnDiskByImageFormat.st
src/PharoLauncher-Download.package/PhLVirtualMachineManager.class/instance/availableVirtualMachinesOnDiskByImageFormat.st
querying
availableVirtualMachinesOnDiskByImageFormat
- ^ self availableVirtualMachinesIn: self privateVmStore
\ No newline at end of file
+ ^[ self availableVirtualMachinesIn: self privateVmStore] on: PhLExecutableNotFoundError do: [ :ex | self privateVmStore deleteAllChildren. ex retry ]
\ No newline at end of file

- Add a cleaning of the vm/private folder in case of error (solve https://github.com/pharo-project/pharo-launcher/issues/88)
- Add new exception if the executable is not found inside the folder
- Minor code cleaning