Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions Sources/SwiftJavaTool/Commands/JExtractCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ extension SwiftJava.JExtractCommand {
config.writeEmptyFiles = writeEmptyFiles
config.unsignedNumbersMode = unsignedNumbers

guard checkModeCompatibility() else {
// check would have logged the reason for early exit.
return
}
try checkModeCompatibility()

if let inputSwift = commonOptions.inputSwift {
config.inputSwiftDirectory = inputSwift
Expand All @@ -108,18 +105,15 @@ extension SwiftJava.JExtractCommand {
}

/// Check if the configured modes are compatible, and fail if not
func checkModeCompatibility() -> Bool {
func checkModeCompatibility() throws {
if self.mode == .jni {
switch self.unsignedNumbers {
case .annotate:
print("Error: JNI mode does not support '\(JExtractUnsignedIntegerMode.wrapGuava)' Unsigned integer mode! \(Self.helpMessage)")
return false
throw IllegalModeCombinationError("JNI mode does not support '\(JExtractUnsignedIntegerMode.wrapGuava)' Unsigned integer mode! \(Self.helpMessage)")
case .wrapGuava:
() // OK
}
}

return true
}
}

Expand All @@ -140,5 +134,12 @@ extension SwiftJava.JExtractCommand {

}

struct IllegalModeCombinationError: Error {
let message: String
init(_ message: String) {
self.message = message
}
}

extension JExtractGenerationMode: ExpressibleByArgument {}
extension JExtractUnsignedIntegerMode: ExpressibleByArgument {}
Loading