packages/bsb-js/utils.js
function processBsbError(err /*: Error | string */) /*: Error[] */ {
  if (typeof err === 'string') {
    const errors = errorRegexes
    // $FlowIssue: err is definitely a string
      .map((r /*: RegExp */) => err.match(r))
      .reduce((a, s) => a.concat(s), [])
      .filter(x => x)

    return (errors.length > 0 ? errors : [err]).map(e => new Error(e))
  } else {
    return [err]
  }
}
function processBsbError(err /*: Error | string */) /*: Error[] */ {
  if (typeof err === 'string') {
    const errors = errorRegexes
    // $FlowIssue: err is definitely a string
      .map((r /*: RegExp */) => err.match(r))
      .reduce((a, s) => a.concat(s), [])
      .filter(x => x)

    return (errors.length > 0 ? errors : [err]).map(e => new Error(e))
  } else {
    return [err]
  }
}
function processBsbError ( err /*: Error | string */ ) /*: Error[] */ { if ( typeof err === 'string' ) { const errors = errorRegexes // $FlowIssue: err is definitely a string . map ( ( r /*: RegExp */ ) => err . match ( r ) ) . reduce ( ( a , s ) => a . concat ( s ) , [ ] ) . filter ( x => x ) return ( errors . length > 0 ? errors : [ err ] ) . map ( e => new Error ( e ) ) } else { return [ err ] } }
This function is only ever called if an error has been caught. We try to process said error according to known formats, but we default to what we got as an argument if they don't match. This way we always throw an error, thus avoiding successful builds if something has gone wrong.
This function is only ever called if an error has been caught . We try to process said error according to known formats but we default to what we got as an argument if they don t match . This way we always throw an error thus avoiding successful builds if something has gone wrong .