Permalink
Browse files

Detection for #792

We need to catch this error somehow.

As it seems this error is suppressed due its location, let’s make it
way more prevalent so we can get this resolved.
  • Loading branch information...
1 parent b3402ab commit d457731e7c657d6970d67d9779583f849a27d23b @balupton balupton committed Feb 21, 2014
Showing with 18 additions and 2 deletions.
  1. +18 −2 src/lib/docpad.coffee
View
@@ -3921,7 +3921,23 @@ class DocPad extends EventEmitterGrouped
# Change event handler
changeHandler = (changeType,filePath,fileCurrentStat,filePreviousStat) ->
- # Fetch the file
+ # Prepare
+ fileEitherStat = (fileCurrentStat or filePreviousStat)
+
+ # For some reason neither of the stats may exist, this will cause errors as this is an invalid state
+ # as we depend on at least one stat existing, otherwise, what on earth is going on?
+ # Whatever the case, this should be fixed within watchr, not docpad
+ # as watchr should not be giving us invalid data
+ # https://github.com/bevry/docpad/issues/792
+ unless fileEitherStat
+ err = new Error("""
+ DocPad has encountered an invalid state while detecting changes for your files.
+ So the DocPad team can fix this right away, please provide any information you can to:
+ https://github.com/bevry/docpad/issues/792
+ """)
+ return docpad.err(err)
+
+ # Log the change
docpad.log 'info', util.format(locale.watchChange, new Date().toLocaleTimeString()), changeType, filePath
# Check if we are a file we don't care about
@@ -3933,7 +3949,7 @@ class DocPad extends EventEmitterGrouped
return
# Don't care if we are a directory
- isDirectory = (fileCurrentStat or filePreviousStat).isDirectory()
+ isDirectory = fileEitherStat.isDirectory()
if isDirectory
docpad.log 'debug', util.format(locale.watchDirectoryChange, new Date().toLocaleTimeString()), filePath
return

0 comments on commit d457731

Please sign in to comment.