• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pgpainless / sop-java / #42

19 Sep 2024 05:38PM UTC coverage: 63.366% (-0.06%) from 63.427%
#42

push

other

vanitasvitae
Fix woodpecker warnings

1107 of 1747 relevant lines covered (63.37%)

0.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/sop-java-picocli/src/main/kotlin/sop/cli/picocli/SOPExceptionExitCodeMapper.kt
1
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
2
//
3
// SPDX-License-Identifier: Apache-2.0
4

5
package sop.cli.picocli
6

7
import picocli.CommandLine.*
8
import sop.exception.SOPGPException
9

10
class SOPExceptionExitCodeMapper : IExitCodeExceptionMapper {
1✔
11

12
    override fun getExitCode(exception: Throwable): Int =
13
        if (exception is SOPGPException) {
1✔
14
            // SOPGPExceptions have well-defined exit code
15
            exception.getExitCode()
1✔
16
        } else if (exception is UnmatchedArgumentException) {
1✔
17
            if (exception.isUnknownOption) {
1✔
18
                // Unmatched option of subcommand (e.g. `generate-key --unknown`)
19
                SOPGPException.UnsupportedOption.EXIT_CODE
1✔
20
            } else {
21
                // Unmatched subcommand
22
                SOPGPException.UnsupportedSubcommand.EXIT_CODE
1✔
23
            }
24
        } else if (exception is MissingParameterException) {
1✔
25
            SOPGPException.MissingArg.EXIT_CODE
×
26
        } else if (exception is ParameterException) {
1✔
27
            // Invalid option (e.g. `--as invalid`)
28
            SOPGPException.UnsupportedOption.EXIT_CODE
1✔
29
        } else {
30
            // Others, like IOException etc.
31
            1
1✔
32
        }
1✔
33
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc