Skip to content

Commit

Permalink
add exception handling for JSON loading
Browse files Browse the repository at this point in the history
  • Loading branch information
fhradilak committed May 20, 2021
1 parent f30007a commit 43f4e44
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ handleLoadJsonButton
| path |
path := UIManager default chooseFileMatching: '*.json'.
path isString
ifTrue: [self loadJson: (FileStream fileNamed: path) contents].
ifTrue: [self loadJsonWithExceptionHandling: (FileStream fileNamed: path) contents].

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
load-json
loadJsonWithExceptionHandling: aText
[self loadJson: aText.
self updateInformationText: 'Animation loaded']
on: KeyNotFound
do: [:error | self updateInformationText: 'Invalid JSON (' , error messageText , ')'].

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"framePropertiesDictionary" : "LW 5/15/2021 14:13",
"getDeepestMorph:at:" : "DM 6/22/2020 01:25",
"handleListenEvent:" : "DM 8/5/2020 21:11",
"handleLoadJsonButton" : "FH 5/20/2021 16:45",
"handleLoadJsonButton" : "FH 5/20/2021 17:46",
"informationBar" : "DM 7/8/2020 15:03",
"informationBar:" : "DM 7/8/2020 15:03",
"informationBarText" : "DM 6/22/2020 01:26",
Expand All @@ -46,13 +46,13 @@
"insertMorph:Into:" : "JIZ 6/3/2020 16:56",
"loadFramesFromJson:with:" : "LW 5/15/2021 14:31",
"loadJson:" : "LW 5/15/2021 14:30",
"loadJsonWithExceptionHandling:" : "FH 5/20/2021 17:44",
"loadMorphs:" : "LW 5/15/2021 14:14",
"loadStartEnd:" : "FH 5/13/2021 10:40",
"loadStartProperties:with:" : "FH 5/15/2021 13:16",
"mainWindow" : "JIZ 6/3/2020 17:04",
"mainWindow:" : "JIZ 6/3/2020 17:04",
"morphTypes" : "LW 5/15/2021 14:00",
"openMorphLoadingField" : "FH 5/20/2021 16:38",
"playAnimations" : "DM 8/5/2020 20:04",
"propertiesDictionary" : "LW 5/15/2021 15:05",
"propertyEditorPanel" : "DM 6/22/2020 01:27",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
initialize-release
testLoadJson
| animationsEditorInstance jsonString data |
| jsonString data |


animationsEditorInstance := AnimationsEditor open.
jsonString := '{"value" : 500}'.
data := STON fromString: jsonString.
self assert: (data at: 'value') = 500.
animationsEditorInstance windowReference abandon.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ testLoadJsonDefaultMorph
| animationsEditorInstance morph |

animationsEditorInstance := AnimationsEditor open.
morph := animationsEditorInstance createMorphFromString: 'Klippschliefer'.
morph := animationsEditorInstance createMorphFromString: 'AnimationsEditorKlippschliefer'.
self assert: morph class = Morph.
animationsEditorInstance windowReference abandon.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ testLoadJsonStartEnd
animationsEditorInstance loadStartEnd: data.
self assert: animationsEditorInstance propertyList first startTime = 0.
self assert: animationsEditorInstance propertyList first endTime = 500.

"self loadMorphs: (data at: 'morphs')."
"animationsEditorInstance loadJSON: "
animationsEditorInstance windowReference abandon.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"testEmptyPanelsSetter" : "DM 8/7/2020 17:37",
"testGetDeepestMorph" : "DM 8/4/2020 13:26",
"testInstanceCreation" : "DM 8/4/2020 13:26",
"testLoadJson" : "LW 5/15/2021 15:32",
"testLoadJson" : "FH 5/20/2021 16:59",
"testLoadJsonCircleMorph" : "LW 5/15/2021 14:49",
"testLoadJsonDefaultMorph" : "LW 5/15/2021 14:50",
"testLoadJsonDefaultMorph" : "FH 5/20/2021 17:49",
"testLoadJsonLoadMorphs" : "LW 5/15/2021 16:58",
"testLoadJsonMorph" : "LW 5/15/2021 14:50",
"testLoadJsonPropertyColor" : "LW 5/15/2021 16:58",
"testLoadJsonPropertyPosition" : "LW 5/15/2021 16:59",
"testLoadJsonPropertyRotation" : "LW 5/15/2021 16:59",
"testLoadJsonPropertySize" : "LW 5/15/2021 16:59",
"testLoadJsonRectangleMorph" : "LW 5/15/2021 14:49",
"testLoadJsonStartEnd" : "LW 5/15/2021 16:59",
"testLoadJsonStartEnd" : "FH 5/20/2021 17:11",
"testLoadJsonTargetColor" : "LW 5/15/2021 16:59",
"testLoadJsonTargetPosition" : "LW 5/15/2021 16:59",
"testLoadJsonTargetRotation" : "LW 5/15/2021 16:59",
Expand Down

0 comments on commit 43f4e44

Please sign in to comment.