@@ -64,8 +64,11 @@ object process {
6464 val raiseError = F .raiseError[List [String ]] _
6565
6666 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 =>
6972 F .blocking(process.waitFor()).flatMap { exitValue =>
7073 if (maxSizeExceeded && ! args.slurpOptions(SlurpOption .IgnoreBufferOverflow ))
7174 raiseError(new ProcessBufferOverflowException (args, buffer, maxBufferSize))
@@ -74,7 +77,7 @@ object process {
7477 else
7578 raiseError(new ProcessFailedException (args, buffer, exitValue))
7679 }
77- }
80+ }
7881
7982 val onTimeout = F .blocking(process.destroyForcibly()) >>
8083 raiseError(new ProcessTimedOutException (args, buffer, timeout))
@@ -133,18 +136,32 @@ object process {
133136 .through(fs2.text.utf8.decode)
134137 .through(fs2.text.linesLimited(maxBufferSize))
135138
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+
136145 final class ProcessBufferOverflowException (
137146 args : Args ,
138147 buffer : ListBuffer [String ],
139148 maxBufferSize : Int
140149 ) 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"
146151 })
147152
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+
148165 final class ProcessFailedException (
149166 args : Args ,
150167 buffer : ListBuffer [String ],
0 commit comments