change exception throwing so we get a reasonable stacktrace
This commit is contained in:
parent
084300bce2
commit
c4a20457de
|
@ -79,7 +79,7 @@ public class Service extends Win32Bindings {
|
||||||
this.manager = OpenSCManager("", SC_MANAGER_ALL_ACCESS);
|
this.manager = OpenSCManager("", SC_MANAGER_ALL_ACCESS);
|
||||||
|
|
||||||
if (this.manager == 0) {
|
if (this.manager == 0) {
|
||||||
Service.throwLastErrorException();
|
throw getLastErrorException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public class Service extends Win32Bindings {
|
||||||
SERVICE_ALL_ACCESS);
|
SERVICE_ALL_ACCESS);
|
||||||
|
|
||||||
if (this.service == 0) {
|
if (this.service == 0) {
|
||||||
Service.throwLastErrorException();
|
throw getLastErrorException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ public class Service extends Win32Bindings {
|
||||||
password);
|
password);
|
||||||
|
|
||||||
if (service.service == 0) {
|
if (service.service == 0) {
|
||||||
Service.throwLastErrorException();
|
throw getLastErrorException();
|
||||||
}
|
}
|
||||||
|
|
||||||
service.setDescription(description);
|
service.setDescription(description);
|
||||||
|
@ -180,7 +180,7 @@ public class Service extends Win32Bindings {
|
||||||
throws Win32Exception
|
throws Win32Exception
|
||||||
{
|
{
|
||||||
if (!ControlService(this.service, control)) {
|
if (!ControlService(this.service, control)) {
|
||||||
Service.throwLastErrorException();
|
throw getLastErrorException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ public class Service extends Win32Bindings {
|
||||||
public void start() throws Win32Exception
|
public void start() throws Win32Exception
|
||||||
{
|
{
|
||||||
if (StartService(this.service) == false) {
|
if (StartService(this.service) == false) {
|
||||||
Service.throwLastErrorException();
|
throw getLastErrorException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ public class Service extends Win32Bindings {
|
||||||
public void stop() throws Win32Exception
|
public void stop() throws Win32Exception
|
||||||
{
|
{
|
||||||
if (StopService(this.service) == false) {
|
if (StopService(this.service) == false) {
|
||||||
Service.throwLastErrorException();
|
throw getLastErrorException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ public class Service extends Win32Bindings {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status != SERVICE_STOPPED) {
|
if (status != SERVICE_STOPPED) {
|
||||||
Service.throwLastErrorException();
|
throw getLastErrorException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,24 +290,23 @@ public class Service extends Win32Bindings {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == false) {
|
if (result == false) {
|
||||||
Service.throwLastErrorException();
|
throw getLastErrorException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceConfig getConfig() throws Win32Exception {
|
public ServiceConfig getConfig() throws Win32Exception {
|
||||||
ServiceConfig config = new ServiceConfig();
|
ServiceConfig config = new ServiceConfig();
|
||||||
if (!QueryServiceConfig(this.service, config)) {
|
if (!QueryServiceConfig(this.service, config)) {
|
||||||
Service.throwLastErrorException();
|
throw getLastErrorException();
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final void throwLastErrorException()
|
private static Win32Exception getLastErrorException()
|
||||||
throws Win32Exception
|
|
||||||
{
|
{
|
||||||
int err = Service.GetLastError();
|
int err = GetLastError();
|
||||||
throw new Win32Exception(err, "Win32 Error Code: " +
|
return new Win32Exception(err, "Win32 Error Code: " +
|
||||||
err + ": " + GetErrorMessage(err));
|
err + ": " + GetErrorMessage(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native boolean ChangeServiceDescription(long handle,
|
private static native boolean ChangeServiceDescription(long handle,
|
||||||
|
|
Loading…
Reference in New Issue