Skip to content

Commit

Permalink
[full ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
richardelms committed Oct 4, 2024
1 parent af3c746 commit 42ee3d4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ void FAndroidPlatformBugsnag::Start(const TSharedRef<FBugsnagConfiguration>& Con
jstring jValue = FAndroidPlatformJNI::ParseFString(Env, BugsnagUtils::GetUnrealEngineVersion());
(*Env).CallVoidMethod(jClient, JNICache.ClientAddRuntimeVersionInfo, jKey, jValue);
FAndroidPlatformJNI::CheckAndClearException(Env);
UE_LOG(LogBugsnag, Error, TEXT("RICHLOG JNICache loaded"));

}
}else{
UE_LOG(LogBugsnag, Error, TEXT("RICHLOG JNICache NOT loaded"));
Expand All @@ -57,19 +59,25 @@ void FAndroidPlatformBugsnag::Start(const TSharedRef<FBugsnagConfiguration>& Con
void FAndroidPlatformBugsnag::Notify(const FString& ErrorClass, const FString& Message, const TArray<uint64>& StackTrace,
const FBugsnagOnErrorCallback& Callback)
{
UE_LOG(LogBugsnag, Error, TEXT("RICHLOG NOTIFY: 1"));

JNIEnv* Env = AndroidJavaEnv::GetJavaEnv(true);
ReturnVoidIf(!Env || !JNICache.initialized);
UE_LOG(LogBugsnag, Error, TEXT("RICHLOG NOTIFY: 2"));

jstring jErrorClass = FAndroidPlatformJNI::ParseFString(Env, ErrorClass);
jstring jMessage = FAndroidPlatformJNI::ParseFString(Env, Message);
ReturnVoidIf(!jErrorClass || !jMessage);
UE_LOG(LogBugsnag, Error, TEXT("RICHLOG NOTIFY: 3"));

jobjectArray jFrames = (*Env).NewObjectArray(StackTrace.Num(), JNICache.TraceClass, NULL);
ReturnVoidIf(!jFrames);
UE_LOG(LogBugsnag, Error, TEXT("RICHLOG NOTIFY: 4"));

// Java class name for each stack frame, intentionally empty
jobject jClassName = (*Env).NewStringUTF("");
ReturnVoidIf(!jClassName);
UE_LOG(LogBugsnag, Error, TEXT("RICHLOG NOTIFY: 5"));

Dl_info Info;
jstring jFilename, jMethod;
Expand Down Expand Up @@ -122,6 +130,8 @@ void FAndroidPlatformBugsnag::Notify(const FString& ErrorClass, const FString& M
(*Env).CallStaticVoidMethod(JNICache.BugsnagUnrealPluginClass,
JNICache.BugsnagUnrealPluginNotify, jErrorClass, jMessage, jFrames, jCallbackBuffer);
FAndroidPlatformJNI::CheckAndClearException(Env);
UE_LOG(LogBugsnag, Error, TEXT("RICHLOG NOTIFY: 6"));

}

const TOptional<FString> FAndroidPlatformBugsnag::GetContext()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,61 +120,61 @@ public void unload() {

static void notify(String name, String message, StackTraceElement[] stacktrace, ByteBuffer userdata) {
try {
Log.e("NotifyMethod", "notify called with name: " + name + ", message: " + message);
Log.e("RICHLOG NotifyMethod", "notify called with name: " + name + ", message: " + message);

if (client == null || name == null) {
Log.e("NotifyMethod", "client is null or name is null. Returning early.");
Log.e("RICHLOG NotifyMethod", "client is null or name is null. Returning early.");
return;
}

if (discardClasses != null) {
for (Pattern pattern : discardClasses) {
if (pattern.matcher(name).matches()) {
Log.e("NotifyMethod", "Name matches discard pattern: " + pattern.toString() + ". Returning.");
Log.e("RICHLOG NotifyMethod", "Name matches discard pattern: " + pattern.toString() + ". Returning.");
return;
}
}
}

Throwable exc = new RuntimeException();
exc.setStackTrace(stacktrace);
Log.e("NotifyMethod", "Exception created and stack trace set.");
Log.e("RICHLOG NotifyMethod", "Exception created and stack trace set.");

try {
client.notify(exc, new OnErrorCallback() {
@Override
public boolean onError(Event event) {
try {
Log.e("NotifyMethod", "onError called with event.");
Log.e("RICHLOG NotifyMethod", "onError called with event.");
setSeverityReason(event, DEFAULT_HANDLED_REASON);
Log.e("NotifyMethod", "Severity reason set to " + DEFAULT_HANDLED_REASON);
Log.e("RICHLOG NotifyMethod", "Severity reason set to " + DEFAULT_HANDLED_REASON);

List<Error> errors = event.getErrors();
if (!errors.isEmpty()) {
Error error = errors.get(0);
error.setErrorClass(name);
error.setErrorMessage(message);
Log.e("NotifyMethod", "Error class set to " + name + " and message set to " + message);
Log.e("RICHLOG NotifyMethod", "Error class set to " + name + " and message set to " + message);

for (Error err : errors) {
err.setType(ErrorType.C);
Log.e("NotifyMethod", "Error type set to C for error.");
Log.e("RICHLOG NotifyMethod", "Error type set to C for error.");
}
}
return runNotifyCallback(event, userdata);
} catch (Exception e) {
Log.e("NotifyMethod", "Exception in onError: " + e.getMessage(), e);
Log.e("RICHLOG NotifyMethod", "Exception in onError: " + e.getMessage(), e);
return false;
}
}
});
} catch (Exception e) {
Log.e("NotifyMethod", "Exception in client.notify: " + e.getMessage(), e);
Log.e("RICHLOG NotifyMethod", "Exception in client.notify: " + e.getMessage(), e);
}

Log.e("NotifyMethod", "Notification sent to Bugsnag.");
Log.e("RICHLOG NotifyMethod", "Notification sent to Bugsnag.");
} catch (Exception e) {
Log.e("NotifyMethod", "Exception in notify method: " + e.getMessage(), e);
Log.e("RICHLOG NotifyMethod", "Exception in notify method: " + e.getMessage(), e);
}
}

Expand Down

0 comments on commit 42ee3d4

Please sign in to comment.