mpd/src/java/Exception.cxx

23 lines
505 B
C++
Raw Normal View History

// SPDX-License-Identifier: BSD-2-Clause
// author: Max Kellermann <max.kellermann@gmail.com>
2019-04-24 13:51:19 +02:00
#include "Exception.hxx"
#include "Object.hxx"
#include "String.hxx"
Java::Exception::Exception(JNIEnv *env, jthrowable e) noexcept
:std::runtime_error(Java::String(env, Object::toString(env, e)).ToString())
{
}
void
Java::RethrowException(JNIEnv *env)
{
LocalRef<jthrowable> exception{env, env->ExceptionOccurred()};
if (!exception)
2019-04-24 13:51:19 +02:00
return;
env->ExceptionClear();
throw Exception(env, exception);
}