libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 094c55e456480aa4be87568cfe36de50583bdf05
parent 0676e25980a8bc6f93c8fef14d94280888167f39
Author: MS <ms@taler.net>
Date:   Fri, 13 Jan 2023 16:46:45 +0100

fix #7513

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 8+++-----
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 28+++++++++++-----------------
2 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -43,9 +43,7 @@ val logger: Logger = LoggerFactory.getLogger("tech.libeufin.nexus") const val NEXUS_DB_ENV_VAR_NAME = "LIBEUFIN_NEXUS_DB_CONNECTION" class NexusCommand : CliktCommand() { - init { - versionOption(getVersion()) - } + init { versionOption(getVersion()) } override fun run() = Unit } @@ -79,7 +77,7 @@ class Serve : CliktCommand("Run nexus HTTP server") { startOperationScheduler(client) if (withUnixSocket != null) { startServer( - withUnixSocket ?: throw Exception("Could not use the Unix domain socket path value!"), + withUnixSocket!!, app = nexusApp ) exitProcess(0) @@ -132,7 +130,7 @@ class Superuser : CliktCommand("Add superuser or change pw") { } } else { if (!user.superuser) { - println("Can only change password for superuser with this command.") + System.err.println("Can only change password for superuser with this command.") throw ProgramResult(1) } user.passwordHash = hashedPw diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt @@ -102,7 +102,7 @@ class DefaultExchange : CliktCommand("Set default Taler exchange for a demobank. DemobankConfigsTable.name eq demobank }.firstOrNull() if (maybeDemobank == null) { - println("Error, demobank ${demobank} not found.") + System.err.println("Error, demobank $demobank not found.") exitProcess(1) } maybeDemobank.suggestedExchangeBaseUrl = exchangeBaseUrl @@ -112,9 +112,7 @@ class DefaultExchange : CliktCommand("Set default Taler exchange for a demobank. } } -class Config : CliktCommand( - "Insert one configuration (a.k.a. demobank) into the database." -) { +class Config : CliktCommand("Insert one configuration (a.k.a. demobank) into the database.") { init { context { helpFormatter = CliktHelpFormatter(showDefaultValues = true) @@ -147,7 +145,7 @@ class Config : CliktCommand( override fun run() { val dbConnString = getDbConnFromEnv(SANDBOX_DB_ENV_VAR_NAME) if (nameArgument != "default") { - println("This version admits only the 'default' name") + System.err.println("This version admits only the 'default' name") exitProcess(1) } execThrowableOrTerminate { @@ -244,8 +242,8 @@ class Camt053Tick : CliktCommand( newStatements[accountIter.label]?.add( getHistoryElementFromTransactionRow(it) ) ?: run { - logger.warn("Array operation failed while building statements for account: ${accountIter.label}") - println("Fatal array error while building the statement, please report.") + logger.error("Array operation failed while building statements for account: ${accountIter.label}") + System.err.println("Fatal array error while building the statement, please report.") exitProcess(1) } } @@ -301,7 +299,7 @@ class MakeTransaction : CliktCommand("Wire-transfer money between Sandbox bank a System.err.println(e.message) exitProcess(1) } catch (e: Exception) { - System.err.println(e) + System.err.println(e.message) exitProcess(1) } } @@ -313,7 +311,6 @@ class ResetTables : CliktCommand("Drop all the tables from the database") { helpFormatter = CliktHelpFormatter(showDefaultValues = true) } } - override fun run() { val dbConnString = getDbConnFromEnv(SANDBOX_DB_ENV_VAR_NAME) execThrowableOrTerminate { @@ -351,7 +348,7 @@ class Serve : CliktCommand("Run sandbox HTTP server") { WITH_AUTH = auth setLogLevel(logLevel) if (WITH_AUTH && adminPassword == null) { - println("Error: auth is enabled, but env LIBEUFIN_SANDBOX_ADMIN_PASSWORD is not." + System.err.println("Error: auth is enabled, but env LIBEUFIN_SANDBOX_ADMIN_PASSWORD is not." + " (Option --no-auth exists for tests)") exitProcess(1) } @@ -359,13 +356,13 @@ class Serve : CliktCommand("Run sandbox HTTP server") { // Refuse to operate without a 'default' demobank. val demobank = getDemobank("default") if (demobank == null) { - println("Sandbox cannot operate without a 'default' demobank.") - println("Please make one with the 'libeufin-sandbox config' command.") + System.err.println("Sandbox cannot operate without a 'default' demobank.") + System.err.println("Please make one with the 'libeufin-sandbox config' command.") exitProcess(1) } if (withUnixSocket != null) { startServer( - withUnixSocket ?: throw Exception("Could not use the Unix domain socket path value!"), + withUnixSocket!!, app = sandboxApp ) exitProcess(0) @@ -429,10 +426,7 @@ fun ensureNonNull(param: String?): String { } class SandboxCommand : CliktCommand(invokeWithoutSubcommand = true, printHelpOnEmptyArgs = true) { - init { - versionOption(getVersion()) - } - + init { versionOption(getVersion()) } override fun run() = Unit }