File tree 2 files changed +12
-10
lines changed
Mythic/Utilities/Legendary
2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ final class Legendary {
59
59
}
60
60
61
61
// MARK: - Methods
62
+ // TODO: FIXME: better error handling using ``UnableToRetrieveError``
62
63
63
64
/**
64
65
Executes Legendary's command-line process with the specified arguments and handles its output and input interactions.
@@ -435,13 +436,13 @@ final class Legendary {
435
436
436
437
let installedData = try JSON ( data: Data ( contentsOf: URL ( filePath: " \( configLocation) /installed.json " ) ) )
437
438
guard let platformString = installedData [ game. id] [ " platform " ] . string else {
438
- throw UnableToGetPlatformError ( )
439
+ throw UnableToRetrieveError ( )
439
440
}
440
441
441
442
switch platformString {
442
443
case " Mac " : return . macOS
443
444
case " Windows " : return . windows
444
- default : throw UnableToGetPlatformError ( )
445
+ default : throw UnableToRetrieveError ( )
445
446
}
446
447
}
447
448
@@ -595,12 +596,8 @@ final class Legendary {
595
596
*/
596
597
static func getGameLaunchArguments( game: Mythic . Game ) throws -> [ String ] {
597
598
let installedData = try JSON ( data: Data ( contentsOf: URL ( filePath: " \( configLocation) /installed.json " ) ) )
598
- guard let platformString = installedData [ game. id] [ " platform " ] . string else {
599
- throw UnableToGetPlatformError ( )
600
- }
601
-
602
599
guard let arguments = installedData [ game. id] [ " launch_parameters " ] . string else {
603
- throw UnableToGetPlatformError ( )
600
+ throw UnableToRetrieveError ( )
604
601
}
605
602
606
603
return arguments. components ( separatedBy: . whitespaces)
Original file line number Diff line number Diff line change @@ -22,9 +22,14 @@ extension Legendary {
22
22
case normal
23
23
case tall
24
24
}
25
-
26
- struct UnableToGetPlatformError : LocalizedError {
27
- var errorDescription : String ? = " Mythic is unable to get the platform of this game. "
25
+
26
+ enum RetrievalType {
27
+ case platform
28
+ case launchArguments
29
+ }
30
+
31
+ struct UnableToRetrieveError : LocalizedError {
32
+ var errorDescription : String ? = " Mythic is unable to retrive the requested metadata for this game. "
28
33
}
29
34
30
35
struct IsNotLegendaryError : LocalizedError {
You can’t perform that action at this time.
0 commit comments