From 72a8f736bfa4cb7b8d4c08c81f398ae6df4d336b Mon Sep 17 00:00:00 2001 From: Tim Mackinnon Date: Mon, 1 Apr 2019 09:46:55 +0100 Subject: [PATCH] IF the submission id is missing, retrieve it and try again (#228) --- dev/src/ExercismTools/ExSolutionIdError.class.st | 5 +++++ dev/src/ExercismTools/ExercismError.class.st | 3 +++ dev/src/ExercismTools/ExercismExercise.class.st | 5 +++++ .../ExercismTools/ExercismFetchCommand.class.st | 5 +++++ .../ExercismTools/ExercismSubmitCommand.class.st | 16 ++++++++++++---- dev/src/ExercismTools/ExercismTest.class.st | 2 +- 6 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 dev/src/ExercismTools/ExSolutionIdError.class.st diff --git a/dev/src/ExercismTools/ExSolutionIdError.class.st b/dev/src/ExercismTools/ExSolutionIdError.class.st new file mode 100644 index 00000000..209b3dd2 --- /dev/null +++ b/dev/src/ExercismTools/ExSolutionIdError.class.st @@ -0,0 +1,5 @@ +Class { + #name : #ExSolutionIdError, + #superclass : #ExercismError, + #category : #'ExercismTools-Core' +} diff --git a/dev/src/ExercismTools/ExercismError.class.st b/dev/src/ExercismTools/ExercismError.class.st index 70728892..dd42bcb1 100644 --- a/dev/src/ExercismTools/ExercismError.class.st +++ b/dev/src/ExercismTools/ExercismError.class.st @@ -1,3 +1,6 @@ +" +I am a hierarchy of Exercism errors, so its east to catch them +" Class { #name : #ExercismError, #superclass : #Error, diff --git a/dev/src/ExercismTools/ExercismExercise.class.st b/dev/src/ExercismTools/ExercismExercise.class.st index d68e1f2d..19f62155 100644 --- a/dev/src/ExercismTools/ExercismExercise.class.st +++ b/dev/src/ExercismTools/ExercismExercise.class.st @@ -325,6 +325,11 @@ ExercismExercise >> topics: aStringArray [ topics := aStringArray ] +{ #category : #accessing } +ExercismExercise >> trackId [ + ^ExercismManager trackId +] + { #category : #accessing } ExercismExercise >> unlockReference [ "Answer the String unlock reference for a non-core exercise, otherwise nil" diff --git a/dev/src/ExercismTools/ExercismFetchCommand.class.st b/dev/src/ExercismTools/ExercismFetchCommand.class.st index b006c364..fb975cff 100644 --- a/dev/src/ExercismTools/ExercismFetchCommand.class.st +++ b/dev/src/ExercismTools/ExercismFetchCommand.class.st @@ -42,3 +42,8 @@ ExercismFetchCommand >> parser [ ExercismFetchCommand >> parser: aTonelParser [ parser := aTonelParser ] + +{ #category : #internal } +ExercismFetchCommand >> retrieveLatestData [ + ^self subclassResponsibility +] diff --git a/dev/src/ExercismTools/ExercismSubmitCommand.class.st b/dev/src/ExercismTools/ExercismSubmitCommand.class.st index 6f24e1d8..1fa55621 100644 --- a/dev/src/ExercismTools/ExercismSubmitCommand.class.st +++ b/dev/src/ExercismTools/ExercismSubmitCommand.class.st @@ -32,11 +32,19 @@ ExercismSubmitCommand class >> from: anHttpClient exercise: exercise [ { #category : #execution } ExercismSubmitCommand >> execute [ - ^ self - executeCheckingToken: [ - self httpClient + ^ [ self + executeCheckingToken: [ self httpClient patchSolution: self exercise solutionId - with: self exercise solutionSources ] + with: self exercise solutionSources ] ] + on: ExSolutionIdError + do: [ :error | + | submission | + + submission := (ExercismDownloadCommand + track: self exercise trackId + exercise: self exercise name) fetchLatestSubmission. + submission storeSolutionId. + error retry ] ] { #category : #accessing } diff --git a/dev/src/ExercismTools/ExercismTest.class.st b/dev/src/ExercismTools/ExercismTest.class.st index dfb169db..3ca69158 100644 --- a/dev/src/ExercismTools/ExercismTest.class.st +++ b/dev/src/ExercismTools/ExercismTest.class.st @@ -56,7 +56,7 @@ ExercismTest class >> next [ { #category : #accessing } ExercismTest class >> solutionId [ - ^ solutionId ifNil: [ 'missingSolutionId' ] + ^ solutionId ifNil: [ ExSolutionIdError signal: 'Missing exercise solutionId' ] ] { #category : #accessing }