File tree Expand file tree Collapse file tree 1 file changed +22
-20
lines changed
src/main/java/travelator/marketing Expand file tree Collapse file tree 1 file changed +22
-20
lines changed Original file line number Diff line number Diff line change 1
1
package travelator.marketing
2
2
3
- import java.io.Closeable
4
- import java.io.OutputStreamWriter
5
- import java.io.Reader
6
- import java.io.Writer
3
+ import java.io.*
7
4
import kotlin.system.exitProcess
8
5
9
6
fun main () {
10
- val statusCode = using(
11
- System .`in `.reader(),
12
- System .out .writer(),
13
- System .err.writer()
14
- ) { reader, writer, error ->
15
- val errorLines = mutableListOf<ParseFailure >()
16
- val reportLines = reader
17
- .asLineSequence()
18
- .toHighValueCustomerReport {
19
- errorLines + = it
7
+ val statusCode = try {
8
+ using(
9
+ System .`in `.reader(),
10
+ System .out .writer(),
11
+ System .err.writer()
12
+ ) { reader, writer, error ->
13
+ val errorLines = mutableListOf<ParseFailure >()
14
+ val reportLines = reader
15
+ .asLineSequence()
16
+ .toHighValueCustomerReport {
17
+ errorLines + = it
18
+ }
19
+ if (errorLines.isEmpty()) {
20
+ reportLines.writeTo(writer)
21
+ 0
22
+ } else {
23
+ errorLines.writeTo(error)
24
+ - 1
20
25
}
21
- if (errorLines.isEmpty()) {
22
- reportLines.writeTo(writer)
23
- 0
24
- } else {
25
- errorLines.writeTo(error)
26
- - 1
27
26
}
27
+ } catch (x: IOException ) {
28
+ System .err.println (" IO error processing report ${x.message} " )
29
+ - 1
28
30
}
29
31
exitProcess(statusCode)
30
32
}
You can’t perform that action at this time.
0 commit comments