Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Pass dscl create errors up to the ghost user #32

Merged
merged 1 commit into from

3 participants

@turadg

Currently when the create command fails, the add() function simply returns nil and the user never sees the error. They just get a confusing undefined method "name" error exception as in issue #28.

This patch raises an error with the dscl output as its message.

@turadg turadg Pass dscl create errors up to the ghost user
Currently when the `create` command fails, the `add()` function simply returns nil and the user never sees the error. They just get a confusing `undefined method "name" error` exception as in issue #28.

This patch raises an error with the `dscl` output as its message.
ac283bc
@travisbot

This pull request passes (merged ac283bc into f37af28).

@bjeanes bjeanes merged commit 1655cc8 into bjeanes:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 28, 2012
  1. @turadg

    Pass dscl create errors up to the ghost user

    turadg authored
    Currently when the `create` command fails, the `add()` function simply returns nil and the user never sees the error. They just get a confusing `undefined method "name" error` exception as in issue #28.
    
    This patch raises an error with the `dscl` output as its message.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/ghost/mac-host.rb
View
11 lib/ghost/mac-host.rb
@@ -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
Something went wrong with that request. Please try again.