Commit 43826850 authored by Geoff Simmons's avatar Geoff Simmons

Add the admin.GetPanic() method.

parent e67a0f88
......@@ -612,3 +612,27 @@ func (adm *Admin) ActiveVCL() (VCLData, error) {
}
return vcl, nil
}
// GetPanic encapsulates the "panic.show" command. error is non-nil
// when the response was neither of OK or Cant (Cant is the status
// when there was no panic to show). In that case, the error is an
// UnexpectedResponse, which wraps the response from Varnish.
//
// When error is nil, the most recent panic string is returned, or the
// empty string if there has been no panic since Varnish started or
// since the panic was cleared.
func (adm *Admin) GetPanic() (string, error) {
resp, err := adm.Command("panic.show")
if err != nil {
return "", err
}
if resp.Code == Cant {
// Don't panic!
return "", nil
}
if resp.Code != OK {
badResp := UnexpectedResponse{Response: resp}
return "", badResp
}
return resp.Msg, nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment