Skip to content

Commit 87dec16

Browse files
committed
Handle error message properly in capacitor plugin
1 parent f8eb939 commit 87dec16

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

packages/authgear-capacitor/android/src/main/java/com/authgear/capacitor/AuthgearPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ private Integer readColorInt(PluginCall call, String key) {
493493
}
494494

495495
private void reject(PluginCall call, Exception e) {
496-
call.reject(e.getMessage(), e.getClass().getName(), e);
496+
call.reject(e.getLocalizedMessage(), e.getClass().getName(), e);
497497
}
498498

499499
private void rejectWithCancel(PluginCall call) {

packages/authgear-capacitor/src/error.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ export function _wrapError(e: unknown): unknown {
173173
return err;
174174
}
175175
}
176-
const err = new AuthgearError();
176+
const message = typeof e === "object" ? (e as any).message : "";
177+
const err = new AuthgearError(message);
177178
err.underlyingError = e;
178179
return err;
179180
}

0 commit comments

Comments
 (0)