Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix/parse error stack hermes support #614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 24, 2021
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
3 changes: 2 additions & 1 deletion modules/CrashReporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default {
* @param errorObject Error object to be sent to Instabug's servers
*/
reportJSException: function(errorObject) {
let jsStackTrace = InstabugUtils.parseErrorStack(errorObject);
let jsStackTrace = InstabugUtils.getStackTrace(errorObject);

var jsonObject = {
message: errorObject.name + ' - ' + errorObject.message,
os: Platform.OS,
Expand Down
20 changes: 18 additions & 2 deletions utils/InstabugUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@ function getFullRoute(state) {
}
}

export const getStackTrace = (e) => {
let jsStackTrace;
if (Platform.hasOwnProperty("constants")) {
// RN version >= 0.63
if (Platform.constants.reactNativeVersion.minor >= 64)
// RN version >= 0.64 -> Stacktrace as string
jsStackTrace = parseErrorStackLib(e.stack);
// RN version == 0.63 -> Stacktrace as string
else jsStackTrace = parseErrorStackLib(e);
}
// RN version < 0.63 -> Stacktrace as string
else jsStackTrace = parseErrorStackLib(e);
return jsStackTrace;
};

export const isOnReportHandlerSet = () => {
return _isOnReportHandlerSet;
};
Expand All @@ -52,7 +67,7 @@ export const captureJsErrors = () => {
}

function errorHandler(e, isFatal) {
let jsStackTrace = parseErrorStackLib(e);
let jsStackTrace = getStackTrace(e);

//JSON object to be sent to the native SDK
var jsonObject = {
Expand Down Expand Up @@ -91,5 +106,6 @@ export default {
setOnReportHandler,
isOnReportHandlerSet,
getActiveRouteName,
getFullRoute
getFullRoute,
getStackTrace,
};