<commit_before>import ParkAndRideOverlay from '@opentripplanner/park-and-ride-overlay'
import React, { Component } from 'react'
import { connect } from 'react-redux'

import { setLocation } from '../../actions/map'
import { parkAndRideQuery } from '../../actions/api'

class ConnectedParkAndRideOverlay extends Component {
  componentDidMount () {
    const params = {}
    if (this.props.maxTransitDistance) {
      params.maxTransitDistance = this.props.maxTransitDistance
    }
    // TODO: support config-defined bounding envelope

    this.props.parkAndRideQuery(params)
  }

  render () {
    return (
      <ParkAndRideOverlay {...this.props} />
    )
  }
}

// connect to the redux store

const mapStateToProps = (state, ownProps) => {
  return {
    parkAndRideLocations: state.otp.overlay.parkAndRide?.locations &&
      state.otp.overlay.parkAndRide.locations
  }
}

const mapDispatchToProps = {
  parkAndRideQuery,
  setLocation
}

export default connect(mapStateToProps, mapDispatchToProps)(ConnectedParkAndRideOverlay)
<commit_msg>refactor(connected-park-and-ride-overlay): make overlay more robust to errors<commit_after>import ParkAndRideOverlay from '@opentripplanner/park-and-ride-overlay'
import React, { Component } from 'react'
import { connect } from 'react-redux'

import { setLocation } from '../../actions/map'
import { parkAndRideQuery } from '../../actions/api'

class ConnectedParkAndRideOverlay extends Component {
  componentDidMount () {
    const params = {}
    if (this.props.maxTransitDistance) {
      params.maxTransitDistance = this.props.maxTransitDistance
    }
    // TODO: support config-defined bounding envelope

    this.props.parkAndRideQuery(params)
  }

  render () {
    return (
      <ParkAndRideOverlay {...this.props} />
    )
  }
}

// connect to the redux store

const mapStateToProps = (state, ownProps) => {
  const { locations } = state.otp.overlay?.parkAndRide

  // object type indicates error
  if (typeof locations === 'object') {
    return {}
  }

  return {
    parkAndRideLocations: locations
  }
}

const mapDispatchToProps = {
  parkAndRideQuery,
  setLocation
}

export default connect(mapStateToProps, mapDispatchToProps)(ConnectedParkAndRideOverlay)

{'fraction_non_alphanumeric': 0.11256190904997748, 'fraction_numerical': 0.0, 'mean_word_length': 3.747863247863248, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2976237', 'n_tokens_mistral': 693, 'n_tokens_neox': 687, 'n_words': 143}