Skip to content

Commit 040c774

Browse files
committed
Chagne try catching of undefined scalajs property to js.typeOf
1 parent 84feae8 commit 040c774

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

scaladoc-js/src/versions-dropdown/DropdownHandler.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ class DropdownHandler:
4040

4141
window.sessionStorage.getItem(KEY) match
4242
case null => // If no key, returns null
43-
try
44-
getURLContent(Globals.versionsDictionaryUrl).onComplete {
45-
case Success(json: String) =>
46-
window.sessionStorage.setItem(KEY, json)
47-
addVersionsList(json)
48-
case Failure(_) =>
49-
window.sessionStorage.setItem(KEY, UNDEFINED_VERSIONS)
50-
disableButton()
51-
}
52-
catch // Globals.versionDictionaruUrl is undefined
53-
case e =>
43+
js.typeOf(Globals.versionsDictionaryUrl) match
44+
case "undefined" =>
5445
window.sessionStorage.setItem(KEY, UNDEFINED_VERSIONS)
5546
disableButton()
47+
case _ =>
48+
getURLContent(Globals.versionsDictionaryUrl).onComplete {
49+
case Success(json: String) =>
50+
window.sessionStorage.setItem(KEY, json)
51+
addVersionsList(json)
52+
case Failure(_) =>
53+
window.sessionStorage.setItem(KEY, UNDEFINED_VERSIONS)
54+
disableButton()
55+
}
5656
case value => value match
5757
case UNDEFINED_VERSIONS =>
5858
disableButton()

0 commit comments

Comments
 (0)