Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 21 additions & 27 deletions ink/jni/internal/status_native.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

namespace {

void ThrowExceptionFromStatus(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
absl::Status status) {
throw_exception_from_status_callback(jni_env_pass_through,
static_cast<int>(status.code()),
status.ToString().c_str());
void ThrowExceptionFromStatus(void* jni_env_pass_through,
void (*throw_from_status_callback)(void*, int,
const char*),
absl::Status status) {
throw_from_status_callback(jni_env_pass_through,
static_cast<int>(status.code()),
status.ToString().c_str());
}

} // namespace
Expand Down Expand Up @@ -57,63 +57,57 @@ int StatusNative_statusCodeUnimplemented() {

void StatusNative_throwExceptionFromOkStatusForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*)) {
ThrowExceptionFromStatus(jni_env_pass_through,
throw_exception_from_status_callback,
void (*throw_from_status_callback)(void*, int, const char*)) {
ThrowExceptionFromStatus(jni_env_pass_through, throw_from_status_callback,
absl::OkStatus());
}

void StatusNative_throwExceptionFromFailedPreconditionForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
void (*throw_from_status_callback)(void*, int, const char*),
const char* message) {
ThrowExceptionFromStatus(jni_env_pass_through,
throw_exception_from_status_callback,
ThrowExceptionFromStatus(jni_env_pass_through, throw_from_status_callback,
absl::FailedPreconditionError(message));
}

void StatusNative_throwExceptionFromInvalidArgumentForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
void (*throw_from_status_callback)(void*, int, const char*),
const char* message) {
ThrowExceptionFromStatus(jni_env_pass_through,
throw_exception_from_status_callback,
ThrowExceptionFromStatus(jni_env_pass_through, throw_from_status_callback,
absl::InvalidArgumentError(message));
}

void StatusNative_throwExceptionFromNotFoundForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
void (*throw_from_status_callback)(void*, int, const char*),
const char* message) {
ThrowExceptionFromStatus(jni_env_pass_through,
throw_exception_from_status_callback,
ThrowExceptionFromStatus(jni_env_pass_through, throw_from_status_callback,
absl::NotFoundError(message));
}

void StatusNative_throwExceptionFromOutOfRangeForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
void (*throw_from_status_callback)(void*, int, const char*),
const char* message) {
ThrowExceptionFromStatus(jni_env_pass_through,
throw_exception_from_status_callback,
ThrowExceptionFromStatus(jni_env_pass_through, throw_from_status_callback,
absl::OutOfRangeError(message));
}

void StatusNative_throwExceptionFromUnimplementedForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
void (*throw_from_status_callback)(void*, int, const char*),
const char* message) {
ThrowExceptionFromStatus(jni_env_pass_through,
throw_exception_from_status_callback,
ThrowExceptionFromStatus(jni_env_pass_through, throw_from_status_callback,
absl::UnimplementedError(message));
}

void StatusNative_throwExceptionFromUnknownStatusCodeForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
void (*throw_from_status_callback)(void*, int, const char*),
int status_code, const char* message) {
ThrowExceptionFromStatus(
jni_env_pass_through, throw_exception_from_status_callback,
jni_env_pass_through, throw_from_status_callback,
absl::Status(absl::StatusCode(status_code), message));
}

Expand Down
14 changes: 7 additions & 7 deletions ink/jni/internal/status_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,36 @@ int StatusNative_statusCodeUnimplemented();

void StatusNative_throwExceptionFromOkStatusForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*));
void (*throw_from_status_callback)(void*, int, const char*));

void StatusNative_throwExceptionFromFailedPreconditionForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
void (*throw_from_status_callback)(void*, int, const char*),
const char* message);

void StatusNative_throwExceptionFromInvalidArgumentForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
void (*throw_from_status_callback)(void*, int, const char*),
const char* message);

void StatusNative_throwExceptionFromNotFoundForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
void (*throw_from_status_callback)(void*, int, const char*),
const char* message);

void StatusNative_throwExceptionFromOutOfRangeForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
void (*throw_from_status_callback)(void*, int, const char*),
const char* message);

void StatusNative_throwExceptionFromUnimplementedForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
void (*throw_from_status_callback)(void*, int, const char*),
const char* message);

void StatusNative_throwExceptionFromUnknownStatusCodeForTesting(
void* jni_env_pass_through,
void (*throw_exception_from_status_callback)(void*, int, const char*),
void (*throw_from_status_callback)(void*, int, const char*),
int status_code, const char* message);

#ifdef __cplusplus
Expand Down
Loading