csv: Throw exceptions with context
Feature Request
| Q | A |
|---|---|
| New Feature | yes |
| BC Break | yes |
Proposal
Whenever an exception is thrown it is always a native Exception. This can make it hard to figure out what has gone wrong if the CSV handling is just part of a larger process.
I would like to see native League\Csv\Exception errors being throw to give some context, for example StreamException or HeaderException.
I’m very happy to do this work if there’s a good chance of it being merged.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (15 by maintainers)
I’ve made a list of existing exceptions against what seems to make sense against your suggestions. I don’t obviously see where
CannotReadRecordfits so maybe we don’t need that? I do wonder if aStreamExceptionwould be usefulSyntaxErrorCannotReadRecordCannotAddStreamFilterInvalidArgumentAbstractCsv::__cloneAbstractCsv::chunkAbstractCsv::sendHeadersAbstractCsv::setDelimiterAbstractCsv::setEnclosureAbstractCsv::setEscapeAbstractCsv::addStreamFilterColumnConsistency::__constructReader::setHeaderReader::setHeaderOffsetReader::computeHeaderResultSet::fetchOneResultSet::getColumnIndexByValueResultSet::getColumnIndexByKey: 197ResultSet::getColumnIndexByKey: 209Statement::offsetStatement::limitStream::__cloneStream::createFromPathStream::appendFilterStream::filterControl:267Stream::filterControl:271Stream::filterControl:278Stream::rewindStream::seekStream::fseekWriter::setFlushThresholdGreat, I’ll try and get that sorted out later today