CSV.swift icon indicating copy to clipboard operation
CSV.swift copied to clipboard

error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.

Open youssefavx opened this issue 5 years ago • 2 comments

Sorry if this is too simple but I'm quite new to Swift so this is all unfamiliar to me. I pasted this code into xcode and got the error above:

import Foundation
import CSV

let stream = OutputStream(toFileAtPath: "file.csv", append: false)!
let csv = try! CSVWriter(stream: stream)

try! csv.write(row: ["id", "name"])
try! csv.write(row: ["1", "foo"])
try! csv.write(row: ["1", "bar"])

csv.stream.close()

Particularly it was pointing at this line: let csv = try! CSVWriter(stream: stream)

In what seems to be the console, I got this:

Fatal error: 'try!' expression unexpectedly raised an error: CSV.CSVError.cannotOpenFile: file /BuildRoot/Library/Caches/com.apple.xbs/Sources/swiftlang_Fall2018/swiftlang_Fall2018-1000.11.42/src/swift/stdlib/public/core/ErrorType.swift, line 184

youssefavx avatar Aug 21 '20 06:08 youssefavx

@youssefavx Hi, did you by any chance solve this issue? I'm having the same problem here.

davidecastello avatar Oct 30 '20 14:10 davidecastello

@davidecastello Unfortunately not :/ haven't gone back to Swift since then, but if I ever do, reading and writing CSV files is something I do frequently so I might stumble into this situation once more in the future and try to debug.

youssefavx avatar Oct 30 '20 21:10 youssefavx