Skip to content

Errors

Nothing throws, so the SDK can't crash your app. Every call returns, and every error goes to FlutterError.onError with library == 'plingbuddy', as a PlingBuddyError with a code, a message, the field it concerns if any, and transient.

Transient errors are reported as silent, so by default they're only printed in debug builds. Everything else is reported normally.

  • Errors that pass by themselves have transient set, and the SDK sends again by itself: after the wait the service asked for, or after 30 seconds, doubling up to 15 minutes.
Code When
unreachable No network, or a timeout.
server_error A server error on the service.
rate_limited The service asked the device to wait.
access_denied A 401 or 403 from something between the device and the service, such as a proxy or firewall.
  • Everything else is usually a mistake to fix in the app:
Code When
not_initialized A call before the first initialize.
invalid_argument The app passed data that breaks a data rule; field names it. Nothing was stored.
invalid_application The service doesn't know the application id.
field_refused The service refused a field; field names it. A field the request carried was dropped; otherwise it's only named as possibly wrong.
external_id_refused The service refused the external id; the user went back to the previous one.
request_refused The service refused the request for another reason. The sync stops until the next initialize.
setup_error The service keeps answering that the installation doesn't exist, for example because of a wrong baseUrl. The sync stops until the next initialize.
identity_setup_error Identity tokens keep being refused, or none can be had. See identity verification on the Users and data page.
identity_mismatch The identity token is for another user.
identity_verification_required deleteRecipient for a signed-in user, while the application doesn't verify identities. Your backend has to erase the user another way.
storage_error The SDK's state file can't be written, or a corrupt one was set aside.
permission_error The platform failed while asking for permission or reading the push token.

Errors never contain the device's credentials, push token or identity token.

On web and desktop, the plugin itself reports unsupported_platform for every call.

Acting on errors

To act on the errors yourself, wrap the handler that is already set, so a crash reporter that installed its own still gets every report. Set this after the crash reporter's setup:

Dart
final previousOnError = FlutterError.onError;
FlutterError.onError = (details) {
  if (details.library == 'plingbuddy' && !details.silent) {
    final error = details.exception;
    // E.g. error is PlingBuddyError && error.code == 'invalid_application'.
  }
  previousOnError?.call(details);
};