mpd/src/java/Exception.cxx
2023-03-06 14:59:48 +01:00

23 lines
505 B
C++

// SPDX-License-Identifier: BSD-2-Clause
// author: Max Kellermann <max.kellermann@gmail.com>
#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)
return;
env->ExceptionClear();
throw Exception(env, exception);
}