improve readability of error messages for filename of config

This commit is contained in:
ansgarz 2022-03-05 09:26:48 +01:00
parent d2f84153e0
commit 03cd8f4b2b
2 changed files with 5 additions and 5 deletions

View file

@ -23,12 +23,12 @@ fun main(args: Array<String>) {
provisionDesktop(prov, cmd) provisionDesktop(prov, cmd)
} catch (e: SerializationException) { } catch (e: SerializationException) {
println( 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) { } catch (e: FileNotFoundException) {
println( println(
"Error: File\u001b[31m ${cmd.configFile} \u001b[0m was not found.\n" + "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} \u001B[0m " + "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" "and change the content according to your needs.\n"
) )
} }

View file

@ -110,7 +110,7 @@ internal class CliWorkplaceKtTest {
System.setErr(originalErr) System.setErr(originalErr)
val expectedOutput = 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", "")) assertEquals(expectedOutput, outContent.toString().replace("\r", "").replace("\n", ""))
verify(exactly = 0) { any<Prov>().provisionWorkplace(any(), any(), any(), any(), any(), ) } verify(exactly = 0) { any<Prov>().provisionWorkplace(any(), any(), any(), any(), any(), ) }
@ -137,7 +137,7 @@ internal class CliWorkplaceKtTest {
System.setErr(originalErr) System.setErr(originalErr)
val expectedOutput = 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", "")) assertEquals(expectedOutput, outContent.toString().replace("\r", "").replace("\n", ""))
verify(exactly = 0) { any<Prov>().provisionWorkplace(any(), any(), any(), any(), any(), ) } verify(exactly = 0) { any<Prov>().provisionWorkplace(any(), any(), any(), any(), any(), ) }