Permalink
Browse files

Get first error from Iterable collection

  • Loading branch information...
Kikobeats committed Sep 16, 2018
1 parent 8f1a688 commit 85a74bfcd4315a62de423083d5c6a1fbc288c88a
Showing with 8 additions and 5 deletions.
  1. +7 −5 bin/cli/pretty-error.js
  2. +1 −0 package.json
@@ -1,8 +1,9 @@
'use strict'
const { castArray, first } = require('lodash')
const PrettyError = require('pretty-error')
const cleanStack = require('clean-stack')
const { chain } = require('lodash')
const isIterable = require('is-iterable')
const pe = new PrettyError()
@@ -46,9 +47,10 @@ const renderError = error => {
}
module.exports = genericError => {
const error = chain(genericError)
.castArray()
.first()
.value()
const error = first(
isIterable(genericError)
? Array.from(genericError)
: castArray(genericError)
)
return renderError(error)
}
@@ -38,6 +38,7 @@
"clean-stack": "~1.3.0",
"cosmiconfig": "~5.0.6",
"github-build": "~1.2.0",
"is-iterable": "~1.1.1",
"lodash": "~4.17.10",
"meow": "~5.0.0",
"neat-log": "~3.1.0",

0 comments on commit 85a74bf

Please sign in to comment.