From cdcee897ec09599cc9c257cb987d1cc6ad87b8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Thu, 1 Jun 2017 03:29:09 +0200 Subject: [PATCH] Added missing error message when input file does not exist. --- CHANGELOG.md | 4 ++++ include/anthem/Exception.h | 4 ++-- src/anthem/Translation.cpp | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9ead11..3fecfab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ Features: * unique IDs for all variables (user-defined variables are renamed) +Bug Fixes: + +* adds missing error message when attempting to read inaccessible file + ## 0.1.5 (2017-05-04) Bug Fixes: diff --git a/include/anthem/Exception.h b/include/anthem/Exception.h index 0390426..685535c 100644 --- a/include/anthem/Exception.h +++ b/include/anthem/Exception.h @@ -29,9 +29,9 @@ class Exception: public std::exception { } - // TODO: set plain message as well explicit Exception(const std::string &message) - : m_message{message} + : m_message{message}, + m_plainMessage{message} { } diff --git a/src/anthem/Translation.cpp b/src/anthem/Translation.cpp index 79e2c5e..ab46e0f 100644 --- a/src/anthem/Translation.cpp +++ b/src/anthem/Translation.cpp @@ -27,6 +27,9 @@ void translate(const std::vector &fileNames, Context &context) { std::ifstream file(fileName, std::ios::in); + if (!file.is_open()) + throw LogicException("could not read file “" + fileName + "”"); + translate(fileName.c_str(), file, context); } }