storeServerpodCloudAuthData static method

Future<void> storeServerpodCloudAuthData({
  1. required ServerpodCloudAuthData authData,
  2. required String localStoragePath,
})

Stores Serverpod Cloud authentication data to local storage.

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

Implementation

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