Ensure that exceptions are logged.
This commit is contained in:
parent
d1b9c5a520
commit
d9cbc03c9f
34
main.cpp
34
main.cpp
@ -37,12 +37,12 @@ using namespace spirv_cross;
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
|
#ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
|
||||||
#define THROW(x) \
|
static inline void THROW(const char *str)
|
||||||
do \
|
{
|
||||||
{ \
|
fprintf(stderr, "SPIRV-Cross will abort: %s\n", str);
|
||||||
fprintf(stderr, "%s.", x); \
|
fflush(stderr);
|
||||||
exit(1); \
|
abort();
|
||||||
} while (0)
|
}
|
||||||
#else
|
#else
|
||||||
#define THROW(x) throw runtime_error(x)
|
#define THROW(x) throw runtime_error(x)
|
||||||
#endif
|
#endif
|
||||||
@ -593,7 +593,7 @@ void rename_interface_variable(Compiler &compiler, const vector<Resource> &resou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
static int main_inner(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
CLIArguments args;
|
CLIArguments args;
|
||||||
CLICallbacks cbs;
|
CLICallbacks cbs;
|
||||||
@ -856,4 +856,24 @@ int main(int argc, char *argv[])
|
|||||||
write_string_to_file(args.output, glsl.c_str());
|
write_string_to_file(args.output, glsl.c_str());
|
||||||
else
|
else
|
||||||
printf("%s", glsl.c_str());
|
printf("%s", glsl.c_str());
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
|
||||||
|
return main_inner(argc, argv);
|
||||||
|
#else
|
||||||
|
// Make sure we catch the exception or it just disappears into the aether on Windows.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return main_inner(argc, argv);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "SPIRV-Cross threw an exception: %s\n", e.what());
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ namespace spirv_cross
|
|||||||
#else
|
#else
|
||||||
fprintf(stderr, "There was a compiler error: %s\n", msg.c_str());
|
fprintf(stderr, "There was a compiler error: %s\n", msg.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
fflush(stderr);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user