Skip to content

Commit

Permalink
IF the submission id is missing, retrieve it and try again (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
macta committed Apr 1, 2019
1 parent e43fdae commit 72a8f73
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
5 changes: 5 additions & 0 deletions dev/src/ExercismTools/ExSolutionIdError.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #ExSolutionIdError,
#superclass : #ExercismError,
#category : #'ExercismTools-Core'
}
3 changes: 3 additions & 0 deletions dev/src/ExercismTools/ExercismError.class.st
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"
I am a hierarchy of Exercism errors, so its east to catch them
"
Class {
#name : #ExercismError,
#superclass : #Error,
Expand Down
5 changes: 5 additions & 0 deletions dev/src/ExercismTools/ExercismExercise.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions dev/src/ExercismTools/ExercismFetchCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ ExercismFetchCommand >> parser [
ExercismFetchCommand >> parser: aTonelParser [
parser := aTonelParser
]

{ #category : #internal }
ExercismFetchCommand >> retrieveLatestData [
^self subclassResponsibility
]
16 changes: 12 additions & 4 deletions dev/src/ExercismTools/ExercismSubmitCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion dev/src/ExercismTools/ExercismTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ExercismTest class >> next [

{ #category : #accessing }
ExercismTest class >> solutionId [
^ solutionId ifNil: [ 'missingSolutionId' ]
^ solutionId ifNil: [ ExSolutionIdError signal: 'Missing exercise solutionId' ]
]

{ #category : #accessing }
Expand Down

0 comments on commit 72a8f73

Please sign in to comment.