Chat: a reply stopped by BroV itself is not an error
claude catches SIGTERM and exits 143, so a reply cancelled by a new message, a new dialog or a closed tab showed «claude: код выхода 143». Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -147,7 +147,11 @@ final class ClaudeCodeCLI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.waitUntilExit()
|
p.waitUntilExit()
|
||||||
|
// cancel() (new message, new dialog, closed tab) drops our reference before the
|
||||||
|
// process dies; `claude` catches SIGTERM and exits 143 instead of dying on the signal.
|
||||||
|
let stoppedByUs = process !== p
|
||||||
if process === p { process = nil }
|
if process === p { process = nil }
|
||||||
|
if stoppedByUs && parser.finalText == nil { throw CancellationError() }
|
||||||
|
|
||||||
if let error = parser.errorMessage {
|
if let error = parser.errorMessage {
|
||||||
if error.localizedCaseInsensitiveContains("authenticate") || error.localizedCaseInsensitiveContains("login") {
|
if error.localizedCaseInsensitiveContains("authenticate") || error.localizedCaseInsensitiveContains("login") {
|
||||||
@@ -161,6 +165,9 @@ final class ClaudeCodeCLI {
|
|||||||
if p.terminationReason == .uncaughtSignal { throw CancellationError() }
|
if p.terminationReason == .uncaughtSignal { throw CancellationError() }
|
||||||
if parser.finalText == nil, p.terminationStatus != 0 {
|
if parser.finalText == nil, p.terminationStatus != 0 {
|
||||||
let stderr = String(data: err.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? ""
|
let stderr = String(data: err.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? ""
|
||||||
|
if p.terminationStatus == 143 || p.terminationStatus == 130 {
|
||||||
|
throw ClaudeCodeCLIError.failed("Ответ прерван: процесс claude остановили снаружи. Отправь сообщение ещё раз.")
|
||||||
|
}
|
||||||
let last = stderr.split(separator: "\n").last.map(String.init) ?? "код выхода \(p.terminationStatus)"
|
let last = stderr.split(separator: "\n").last.map(String.init) ?? "код выхода \(p.terminationStatus)"
|
||||||
throw ClaudeCodeCLIError.failed("claude: \(last)")
|
throw ClaudeCodeCLIError.failed("claude: \(last)")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user