throw site 확정
파일 없음, 파싱 오류, precondition 위반을 구분하고 예외 타입에 context를 싣는다.
throw by value, catch by reference예외가 던져지면 현재 실행은 중단되고 handler를 찾을 때까지 스택이 되감긴다. 이때 지역 객체 소멸, 객체 불변식, noexcept 경계가 동시에 안전해야 한다.
파일 없음, 파싱 오류, precondition 위반을 구분하고 예외 타입에 context를 싣는다.
throw by value, catch by reference예외가 지나가는 프레임마다 지역 객체 소멸자가 역순으로 호출되어 파일, 메모리, lock을 닫는다.
destructor는 밖으로 던지지 않는다가장 가까운 matching catch가 복구, 변환, 재던지기 중 하나를 수행하고 객체 상태 보장 수준을 지킨다.
catch(...)는 경계 변환에 한정close, delete,
unlock이 빠질 가능성이 없는가.
std::vector<Record> load_records(std::filesystem::path path) {
std::ifstream in(path);
if (!in) throw FileError{};
return parse_records(in);
}