Skip to content

Commit

Permalink
Implemented PrettyError.filterParsedError() and bumped to 0.1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
AriaMinaei committed Feb 17, 2014
1 parent c9d5dde commit f5ebd72
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "pretty-error",
"version": "0.1.16",
"version": "0.1.17",
"description": "Readable errors for node",
"main": "scripts/js/lib/PrettyError.js",
"dependencies": {
"utila": "~0.3",
"renderkid": "~0.2.0-beta.7"
"renderkid": "~0.2.0-beta.10"
},
"devDependencies": {
"coffee-script": "~1.6.3",
Expand Down
44 changes: 42 additions & 2 deletions scripts/coffee/lib/PrettyError.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ module.exports = class PrettyError

@_filterCallbacks = []

@_parsedErrorFilters = []

@_aliases = []

@_renderer = new RenderKid
Expand Down Expand Up @@ -116,7 +118,17 @@ module.exports = class PrettyError

else

@filters.apply @, c.filters
@filter.apply @, c.filters

if c.parsedErrorFilters?

if c.parsedErrorFilters is no

@removeAllParsedErrorFilters()

else

@filterParsedError.apply @, c.parsedErrorFilters

if c.aliases?

Expand Down Expand Up @@ -210,9 +222,27 @@ module.exports = class PrettyError

@

filterParsedError: (callbacks...) ->

@_parsedErrorFilters.push cb for cb in callbacks

@

removeParsedErrorFilter: (callbacks...) ->

array.pluckOneItem(@_parsedErrorFilters, cb) for cb in callbacks

@

removeAllParsedErrorFilters: ->

@_parsedErrorFilters.length = 0

@

setMaxItems: (maxItems = 50) ->

if maxItems is 0 then maxItems = 1000
if maxItems is 0 then maxItems = 50

@_maxItems = maxItems|0

Expand Down Expand Up @@ -270,6 +300,8 @@ module.exports = class PrettyError

e = new ParsedError e

@_applyParsedErrorFiltersOn e

header =

title: do ->
Expand Down Expand Up @@ -383,6 +415,14 @@ module.exports = class PrettyError

return no

_applyParsedErrorFiltersOn: (error) ->

for cb in @_parsedErrorFilters

cb error

return

for prop in ['renderer', 'style'] then do ->

methodName = '_get' + prop[0].toUpperCase() + prop.substr(1, prop.length)
Expand Down

0 comments on commit f5ebd72

Please sign in to comment.