storeServerpodCloudUserData static method

Future<void> storeServerpodCloudUserData({
  1. required ServerpodCloudUserData cloudUserData,
  2. required String localStoragePath,
})

Stores Serverpod Cloud user data to local storage.

Throws LocalDataStorageException if the file cannot be created, serialized, or written.

Implementation

static Future<void> storeServerpodCloudUserData({
  required final ServerpodCloudUserData cloudUserData,
  required final String localStoragePath,
}) async {
  try {
    await LocalStorageManager.storeJsonFile(
      fileName: ResourceManagerConstants.serverpodCloudUserFilePath,
      json: cloudUserData.toJson(),
      localStoragePath: localStoragePath,
    );
  } on CreateException catch (e) {
    throw LocalDataStorageException(
      'Failed to store serverpod cloud user data. error: ${e.error}',
      e,
    );
  } on SerializationException catch (e) {
    throw LocalDataStorageException(
      'Failed to store serverpod cloud user data. error: ${e.error}',
      e,
    );
  } on WriteException catch (e) {
    throw LocalDataStorageException(
      'Failed to store serverpod cloud user data. error: ${e.error}',
      e,
    );
  }
}