From 03cd8f4b2bf224942979ebfa9b7d141015589596 Mon Sep 17 00:00:00 2001 From: ansgarz Date: Sat, 5 Mar 2022 09:26:48 +0100 Subject: [PATCH] improve readability of error messages for filename of config --- .../provs/desktop/application/Application.kt | 6 +++--- .../provs/desktop/application/CliWorkplaceKtTest.kt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/Application.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/Application.kt index d918fc8..0457409 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/Application.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/Application.kt @@ -23,12 +23,12 @@ fun main(args: Array) { provisionDesktop(prov, cmd) } catch (e: SerializationException) { println( - "Error: File \"${cmd.configFile}\" has an invalid format and or invalid data.\n" + "Error: File \"${cmd.configFile?.fileName}\" has an invalid format and or invalid data.\n" ) } catch (e: FileNotFoundException) { println( - "Error: File\u001b[31m ${cmd.configFile} \u001b[0m was not found.\n" + - "Pls copy file \u001B[31m WorkplaceConfigExample.yaml \u001B[0m to file \u001B[31m ${cmd.configFile} \u001B[0m " + + "Error: File\u001b[31m ${cmd.configFile?.fileName} \u001b[0m was not found.\n" + + "Pls copy file \u001B[31m WorkplaceConfigExample.yaml \u001B[0m to file \u001B[31m ${cmd.configFile?.fileName} \u001B[0m " + "and change the content according to your needs.\n" ) } diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/CliWorkplaceKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/CliWorkplaceKtTest.kt index 0abd928..168a15d 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/CliWorkplaceKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/CliWorkplaceKtTest.kt @@ -110,7 +110,7 @@ internal class CliWorkplaceKtTest { System.setErr(originalErr) val expectedOutput = - "Error: File\u001B[31m ConfigFileName(fileName=idontexist.yaml) \u001B[0m was not found.Pls copy file \u001B[31m WorkplaceConfigExample.yaml \u001B[0m to file \u001B[31m ConfigFileName(fileName=idontexist.yaml) \u001B[0m and change the content according to your needs." + "Error: File\u001B[31m idontexist.yaml \u001B[0m was not found.Pls copy file \u001B[31m WorkplaceConfigExample.yaml \u001B[0m to file \u001B[31m idontexist.yaml \u001B[0m and change the content according to your needs." assertEquals(expectedOutput, outContent.toString().replace("\r", "").replace("\n", "")) verify(exactly = 0) { any().provisionWorkplace(any(), any(), any(), any(), any(), ) } @@ -137,7 +137,7 @@ internal class CliWorkplaceKtTest { System.setErr(originalErr) val expectedOutput = - "Error: File \"ConfigFileName(fileName=src/test/resources/InvalidWorkplaceConfig.yaml)\" has an invalid format and or invalid data." + "Error: File \"src/test/resources/InvalidWorkplaceConfig.yaml\" has an invalid format and or invalid data." assertEquals(expectedOutput, outContent.toString().replace("\r", "").replace("\n", "")) verify(exactly = 0) { any().provisionWorkplace(any(), any(), any(), any(), any(), ) }