Permalink
Browse files

Merge pull request #32 from turadg/patch-1

Pass dscl create errors up to the ghost user
  • Loading branch information...
2 parents f37af28 + ac283bc commit 1655cc8100c017667136c4d8f58cd2b2e37633a0 @bjeanes committed Aug 29, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/ghost/mac-host.rb
View
@@ -22,9 +22,14 @@ def add(host, ip = "127.0.0.1", force = false)
ip = Socket.gethostbyname(ip)[3].bytes.to_a.join('.')
end
- `#{CreateCmd % [host, ip]}`
- flush!
- find_by_host(host)
+ # command returns empty iff success
+ errorMessage = `#{CreateCmd % [host, ip]}`
+ if errorMessage
+ raise RuntimeError, "Ghost failed due to dscl error %s" % errorMessage
+ else
+ flush!
+ find_by_host(host)
+ end
else
raise Ghost::RecordExists, "Can not overwrite existing record"
end

0 comments on commit 1655cc8

Please sign in to comment.