Skip to content

Commit 494e65b

Browse files
authored
fix crash because non-numeric id
1 parent d2a4fb0 commit 494e65b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Sources/SwiftyCM/game.swift

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ public struct Game {
2121
/// - Parameter id: The ID of the game on SCM
2222
/// - Throws: `SCMError`
2323
public init(_ id: String) throws {
24-
self.id = id;
24+
guard let intVal = Int(id) else {
25+
throw SCMError.otherApiError;
26+
}
27+
self.id = String(intVal);
2528
guard let e = performGetRequest(url: "https://smashcustommusic.net/json/game/\(self.id)") else {
2629
throw SCMError.httpRequestError
2730
};
@@ -73,4 +76,4 @@ public struct GameListGameField {
7376
throw SCMError.otherApiError
7477
}
7578
}
76-
}
79+
}

0 commit comments

Comments
 (0)