Skip to content

Commit

Permalink
Merge pull request #58 from fingerprintjs/improve-error-reporting-for…
Browse files Browse the repository at this point in the history
…-web

Improve error reporting for web platform
  • Loading branch information
ilfa authored Jan 19, 2024
2 parents 712f50b + 219467f commit 2e7e374
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions lib/fpjs_pro_plugin_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ class FpjsProPluginWeb {
_isExtendedResult = call.arguments['extendedResponseFormat'];
_isInitialized = true;
} catch (e) {
throw unwrapWebError(e as WebException);
if (e is WebException) {
throw unwrapWebError(e);
} else {
throw UnknownError(e.toString());
}
}
}

Expand All @@ -99,7 +103,11 @@ class FpjsProPluginWeb {
fp.get(FingerprintJSGetOptions(linkedId: linkedId, tag: tags)));
return result.visitorId;
} catch (e) {
throw unwrapWebError(e as WebException);
if (e is WebException) {
throw unwrapWebError(e);
} else {
throw UnknownError(e.toString());
}
}
}

Expand Down Expand Up @@ -136,7 +144,11 @@ class FpjsProPluginWeb {
serializedResult
];
} catch (e) {
throw unwrapWebError(e as WebException);
if (e is WebException) {
throw unwrapWebError(e);
} else {
throw UnknownError(e.toString());
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/web_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ FingerprintProError unwrapWebError(WebException error) {
return RequestTimeoutError(message);
}
if (message == FingerprintJS.ERROR_RATE_LIMIT) {
// return RequestTimeoutError(message); ???????
return TooManyRequestError(message);
}
if (message == FingerprintJS.ERROR_FORBIDDEN_ORIGIN) {
return OriginNotAvailableError(message);
Expand Down

0 comments on commit 2e7e374

Please sign in to comment.