From: Jacob Lifshay Date: Thu, 29 Jun 2017 07:25:39 +0000 (-0700) Subject: change json::Source::load_file to produce a more descriptive exception message X-Git-Tag: gsoc-2017~77 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=09fd4df0e2a936cd0f8d445b8f377bb14ad5694c;p=kazan.git change json::Source::load_file to produce a more descriptive exception message --- diff --git a/src/json/source.cpp b/src/json/source.cpp index 833bee1..93e7eba 100644 --- a/src/json/source.cpp +++ b/src/json/source.cpp @@ -102,8 +102,12 @@ Source Source::load_file(const util::filesystem::path &file_path) { // TODO: add code to use mmap std::ifstream is; - is.exceptions(std::ios::badbit | std::ios::failbit); + is.exceptions(std::ios::badbit); is.open(file_path); + if(!is) + throw util::filesystem::filesystem_error( + "open failed", file_path, std::make_error_code(std::io_errc::stream)); + is.exceptions(std::ios::badbit | std::ios::failbit); std::vector buffer; while(is.peek() != std::char_traits::eof()) {