diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-11-04 19:35:04 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-11-04 19:35:04 +0000 |
| commit | 7c96eeaad4586641c5e7a4b00c10138ec0b49c79 (patch) | |
| tree | a3a281cc6f251534a5b3b32f95a8b50cd69eb1e2 /src | |
| parent | a86a0ae23bf373cffce899fa58b7cb6783a47ac0 (diff) | |
Throw an exception if file_to_string fails.
Diffstat (limited to 'src')
| -rw-r--r-- | src/util.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/util.cc b/src/util.cc index d5ba6fab..5a5db98d 100644 --- a/src/util.cc +++ b/src/util.cc @@ -403,13 +403,12 @@ dcp::file_to_string (boost::filesystem::path p, uintmax_t max_length) throw MiscError ("Unexpectedly long file"); } - char* c = new char[len + 1]; - FILE* f = fopen_boost (p, "r"); if (!f) { - return ""; + throw FileError ("could not open file", p, errno); } + char* c = new char[len + 1]; fread (c, 1, len, f); fclose (f); c[len] = '\0'; |
