Use UserError when main hog is missing

Error traps to the debugger and then aborts, which is not appropriate
for a user setup error.
This commit is contained in:
Kp 2015-10-09 02:46:11 +00:00
parent 5fc3e44bee
commit 1d99084026
3 changed files with 17 additions and 2 deletions

View file

@ -25,6 +25,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#pragma once
#include <cstddef>
#include <stdio.h>
#include "dxxsconf.h"
#include <assert.h>
@ -48,7 +49,16 @@ void Error_puts(const char *func, unsigned line, const char *str) __noreturn __a
#define Error_puts(F) Error_puts(__func__, __LINE__,F)
void Error(const char *func, unsigned line, const char *fmt,...) __noreturn __attribute_format_printf(3, 4); //exit with error code=1, print message
#define Error(F,...) dxx_call_printf_checked(Error,(Error_puts),(__func__, __LINE__),(F),##__VA_ARGS__)
void UserError_puts(const char *str) __noreturn __attribute_nonnull();
__noreturn
void UserError_puts(const char *str, std::size_t);
template <std::size_t len>
__noreturn
static inline void UserError_puts(const char (&str)[len])
{
UserError_puts(str, len - 1);
}
void UserError(const char *fmt, ...) __noreturn __attribute_format_printf(1, 2);
#define UserError(F,...) dxx_call_printf_checked(UserError,(UserError_puts),(),(F),##__VA_ARGS__)
#define Assert assert

View file

@ -86,6 +86,11 @@ void (Error_puts)(const char *func, const unsigned line, const char *str)
abort_print_exit_message(exit_message, len);
}
void (UserError_puts)(const char *str, std::size_t len)
{
graceful_print_exit_message(str, len);
}
//terminates with error code 1, printing message
void (Error)(const char *func, const unsigned line, const char *fmt,...)
{

View file

@ -398,7 +398,7 @@ int main(int argc, char *argv[])
"\tIn a subdirectory called 'Data'\n" \
DXX_HOGFILE_APPLICATION_BUNDLE \
"Or use the -hogdir option to specify an alternate location."
Error(DXX_MISSING_HOGFILE_ERROR_TEXT);
UserError(DXX_MISSING_HOGFILE_ERROR_TEXT);
}
#if defined(DXX_BUILD_DESCENT_I)