diff options
author | Adam Borowski <kilobyte@angband.pl> | 2010-08-20 02:12:53 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2010-08-20 02:12:53 +0200 |
commit | b25ec0a923318fd601619cd0bd89a9c262ef74e1 (patch) | |
tree | 38d077a4e21a31ffa6ea0da77978e4e4ccd4adb1 /crawl-ref/source/errors.cc | |
parent | a290ba3a83431e38b1d54ed611e7892e38e0fdfd (diff) | |
download | crawl-ref-b25ec0a923318fd601619cd0bd89a9c262ef74e1.tar.gz crawl-ref-b25ec0a923318fd601619cd0bd89a9c262ef74e1.zip |
The transactional save packager.
Diffstat (limited to 'crawl-ref/source/errors.cc')
-rw-r--r-- | crawl-ref/source/errors.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/crawl-ref/source/errors.cc b/crawl-ref/source/errors.cc new file mode 100644 index 0000000000..b61a9eaf79 --- /dev/null +++ b/crawl-ref/source/errors.cc @@ -0,0 +1,38 @@ +/* + * File: errors.cc + * Summary: Handling of error conditions that are not program bugs. + * Written by: Adam Borowski + */ + +#include <stdarg.h> +#include <errno.h> +#include <string.h> + +#include "AppHdr.h" +#include "libutil.h" +#include "stuff.h" + +void fail(const char *msg, ...) +{ + va_list args; + va_start(args, msg); + std::string buf = vmake_stringf(msg, args); + va_end(args); + + // TODO: throw an exception or sumthing here when expected + end(1, true, buf.c_str()); +} + +void sysfail(const char *msg, ...) +{ + va_list args; + va_start(args, msg); + std::string buf = vmake_stringf(msg, args); + va_end(args); + + buf += ": "; + buf += strerror(errno); + + // TODO: throw an exception or sumthing here when expected + end(1, true, buf.c_str()); +} |