Skip to content

Commit

Permalink
fix(electron): do not log errors when sync layer is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
yousif-bugsnag committed Nov 15, 2023
1 parent 8fcdee2 commit 553f985
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
5 changes: 1 addition & 4 deletions packages/plugin-electron-client-state-persistence/src/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ static bool throw_error_from_status(napi_env env, BECSP_STATUS status) {
const char *code = "BugsnagSyncError";
switch (status) {
case BECSP_STATUS_SUCCESS:
case BECSP_STATUS_NOT_INSTALLED:
return false;
case BECSP_STATUS_INVALID_JSON:
napi_throw_error(env, code, "Failed to convert argument to JSON");
Expand All @@ -95,10 +96,6 @@ static bool throw_error_from_status(napi_env env, BECSP_STATUS status) {
case BECSP_STATUS_NULL_PARAM:
napi_throw_type_error(env, code, "Expected argument to be non-null");
break;
case BECSP_STATUS_NOT_INSTALLED:
napi_throw_error(env, code,
"Sync layer is not installed, first call install()");
break;
case BECSP_STATUS_UNKNOWN_FAILURE:
napi_throw_error(env, code, "Failed to synchronize data");
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,22 @@ describe('handling poor inputs', () => {
expect(update).toThrow('Wrong number of arguments, expected 1')
})
})

describe('handling sync layer not being installed', () => {
it('does not throw when sync layer is not installed', () => {
const updateUser = () => NativeClient.updateUser()
expect(updateUser).not.toThrow()

const updateContext = () => NativeClient.updateContext()
expect(updateContext).not.toThrow()

const updateMetadata = () => NativeClient.updateMetadata()
expect(updateMetadata).not.toThrow()

const updateFeatureFlags = () => NativeClient.updateFeatureFlags()
expect(updateFeatureFlags).not.toThrow()

const leaveBreadcrumb = () => NativeClient.leaveBreadcrumb()
expect(leaveBreadcrumb).not.toThrow()
})
})

0 comments on commit 553f985

Please sign in to comment.