2011-09-09 21:24:18 +02:00
|
|
|
#include "assert.hh"
|
|
|
|
|
2012-10-17 17:01:08 +02:00
|
|
|
#include "exception.hh"
|
|
|
|
|
2011-09-09 21:24:18 +02:00
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2012-10-17 17:01:08 +02:00
|
|
|
struct assert_failed : logic_error
|
2011-09-09 21:24:18 +02:00
|
|
|
{
|
2012-10-17 17:01:08 +02:00
|
|
|
assert_failed(const String& message)
|
|
|
|
: m_message(message) {}
|
2011-09-09 21:24:18 +02:00
|
|
|
|
2012-10-17 17:01:08 +02:00
|
|
|
String description() const override { return m_message; }
|
|
|
|
private:
|
|
|
|
String m_message;
|
|
|
|
};
|
2011-09-09 21:24:18 +02:00
|
|
|
|
2012-10-17 17:01:08 +02:00
|
|
|
void on_assert_failed(const char* message)
|
2012-10-16 16:16:32 +02:00
|
|
|
{
|
2012-10-17 17:01:08 +02:00
|
|
|
int res = system(("xmessage -buttons 'quit:0,ignore:1' '"_str + message + "'").c_str());
|
2012-10-16 16:16:32 +02:00
|
|
|
switch (res)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
throw assert_failed(message);
|
|
|
|
case 1:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-09 21:24:18 +02:00
|
|
|
}
|