@@ -64,8 +64,11 @@ object process {
64
64
val raiseError = F .raiseError[List [String ]] _
65
65
66
66
val result =
67
- readLinesIntoBuffer(process.getInputStream, buffer, maxBufferSize, log).flatMap {
68
- maxSizeExceeded =>
67
+ readLinesIntoBuffer(process.getInputStream, buffer, maxBufferSize, log)
68
+ .adaptErr { case t : fs2.text.LineTooLongException =>
69
+ new ProcessLineTooLongException (args, buffer, maxBufferSize, t)
70
+ }
71
+ .flatMap { maxSizeExceeded =>
69
72
F .blocking(process.waitFor()).flatMap { exitValue =>
70
73
if (maxSizeExceeded && ! args.slurpOptions(SlurpOption .IgnoreBufferOverflow ))
71
74
raiseError(new ProcessBufferOverflowException (args, buffer, maxBufferSize))
@@ -74,7 +77,7 @@ object process {
74
77
else
75
78
raiseError(new ProcessFailedException (args, buffer, exitValue))
76
79
}
77
- }
80
+ }
78
81
79
82
val onTimeout = F .blocking(process.destroyForcibly()) >>
80
83
raiseError(new ProcessTimedOutException (args, buffer, timeout))
@@ -133,18 +136,32 @@ object process {
133
136
.through(fs2.text.utf8.decode)
134
137
.through(fs2.text.linesLimited(maxBufferSize))
135
138
139
+ private val bufferOverflowMessage =
140
+ s " If the process executed normally and the buffer size is just too small, you can " +
141
+ s " increase it with the -- ${Cli .name.maxBufferSize} command-line option and/or open " +
142
+ s " a pull request in ${org.scalasteward.core.BuildInfo .gitHubUrl} that increases the " +
143
+ s " default buffer size. "
144
+
136
145
final class ProcessBufferOverflowException (
137
146
args : Args ,
138
147
buffer : ListBuffer [String ],
139
148
maxBufferSize : Int
140
149
) extends IOException (makeMessage(args, buffer) {
141
- s " outputted more than $maxBufferSize lines. " +
142
- s " If the process executed normally and the buffer size is just too small, you can " +
143
- s " increase it with the -- ${Cli .name.maxBufferSize} command-line option and/or open " +
144
- s " a pull request in ${org.scalasteward.core.BuildInfo .gitHubUrl} that increases the " +
145
- s " default buffer size. "
150
+ s " outputted more than $maxBufferSize lines. $bufferOverflowMessage"
146
151
})
147
152
153
+ final class ProcessLineTooLongException (
154
+ args : Args ,
155
+ buffer : ListBuffer [String ],
156
+ maxBufferSize : Int ,
157
+ cause : fs2.text.LineTooLongException
158
+ ) extends IOException (
159
+ makeMessage(args, buffer) {
160
+ s " outputted a line longer than $maxBufferSize chars. $bufferOverflowMessage"
161
+ },
162
+ cause
163
+ )
164
+
148
165
final class ProcessFailedException (
149
166
args : Args ,
150
167
buffer : ListBuffer [String ],
0 commit comments