tryFetchServerpodCloudData static method

Future<ServerpodCloudData?> tryFetchServerpodCloudData({
  1. required String localStoragePath,
  2. required CommandLogger logger,
})

Implementation

static Future<ServerpodCloudData?> tryFetchServerpodCloudData({
  required final String localStoragePath,
  required final CommandLogger logger,
}) async {
  try {
    return await LocalStorageManager.tryFetchAndDeserializeJsonFile(
      fileName: ResourceManagerConstants.serverpodCloudDataFilePath,
      localStoragePath: localStoragePath,
      fromJson: ServerpodCloudData.fromJson,
    );
  } on ReadException catch (_) {
    logger.error(
        'Could not read file at location ${ResourceManagerConstants.serverpodCloudDataFilePath}.',
        hint:
            'Please check that the Serverpod Cloud CLI has the correct permissions to '
            'read the file. If the problem persists, try deleting the file.');
    return null;
  } on DeserializationException catch (_) {
    return null;
  }
}