message: Split dryRun to separate method, map errors.
diff: @@ -38,6 +38,25 @@ export class DefaultLocationService implements LocationService {
  dryRun: boolean,
  ): Promise<{ location: Location; entities: Entity[] }> {
  if (dryRun) {
  + return this.dryRunCreateLocation(spec);
  + }
  + const location = await this.store.createLocation(spec);
  + return { location, entities: [] };
  + }
  +
  + listLocations(): Promise<Location[]> {
  + return this.store.listLocations();
  + }
  + getLocation(id: string): Promise<Location> {
  + return this.store.getLocation(id);
  + }
  + deleteLocation(id: string): Promise<void> {
  + return this.store.deleteLocation(id);
  + }
  +
  + private async dryRunCreateLocation(
  + spec: LocationSpec,
  + ): Promise<{ location: Location; entities: Entity[] }> {
  const entity = {
  apiVersion: 'backstage.io/v1alpha1',
  kind: 'Location',
  @@ -69,11 +88,12 @@ export class DefaultLocationService implements LocationService {
  entity: currentEntity,
  state,
  });
  +
  if (processed.ok) {
  unprocessedEntities.push(...processed.deferredEntities);
  entities.push(processed.completedEntity);
  } else {
  - throw Error(processed.errors.join(', '));
  + throw Error(processed.errors.map(String).join(', '));
  }
  }
  @@ -82,18 +102,4 @@ export class DefaultLocationService implements LocationService {
  entities,
  };
  }
  -
  - const location = await this.store.createLocation(spec);
  - return { location, entities: [] };
  - }
  -
  - listLocations(): Promise<Location[]> {
  - return this.store.listLocations();
  - }
  - getLocation(id: string): Promise<Location> {
  - return this.store.getLocation(id);
  - }
  - deleteLocation(id: string): Promise<void> {
  - return this.store.deleteLocation(id);
  - }
  }
  