Skip to content

Commit

Permalink
Revert TopshelfExitCode back to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
BlythMeister authored and phatboyg committed Jan 12, 2019
1 parent f0c19b1 commit 9893f23
Showing 1 changed file with 13 additions and 34 deletions.
47 changes: 13 additions & 34 deletions src/Topshelf/TopshelfExitCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,16 @@
// specific language governing permissions and limitations under the License.
namespace Topshelf
{
public struct TopshelfExitCode
{
private readonly int _exitCode;

public TopshelfExitCode(int exitCode)
{
_exitCode = exitCode;
}

public static explicit operator int(TopshelfExitCode topshelfExitCode)
{
return topshelfExitCode._exitCode;
}

// windows service exit code compliant
// https://docs.microsoft.com/en-us/windows/desktop/Debug/system-error-codes
public static TopshelfExitCode Ok { get; } = new TopshelfExitCode(0);
public static TopshelfExitCode ServiceAlreadyInstalled { get; } = new TopshelfExitCode(1242);
public static TopshelfExitCode ServiceNotInstalled { get; } = new TopshelfExitCode(1243);
public static TopshelfExitCode ServiceAlreadyRunning { get; } = new TopshelfExitCode(1056);
public static TopshelfExitCode ServiceNotRunning { get; } = new TopshelfExitCode(1062);
public static TopshelfExitCode ServiceControlRequestFailed { get; } = new TopshelfExitCode(1064);
public static TopshelfExitCode AbnormalExit { get; } = new TopshelfExitCode(1067);

// non-compliant
public static TopshelfExitCode SudoRequired { get; } = new TopshelfExitCode(2);
public static TopshelfExitCode NotRunningOnWindows { get; } = new TopshelfExitCode(11);

public override string ToString()
{
return $"Exit code: {_exitCode}";
}
}
}
public enum TopshelfExitCode
{
Ok = 0,
ServiceAlreadyInstalled = 1242,
ServiceNotInstalled = 1243,
ServiceAlreadyRunning = 1056,
ServiceNotRunning = 1062,
ServiceControlRequestFailed = 1064,
AbnormalExit = 1067,
SudoRequired = 2,
NotRunningOnWindows = 11
}
}

0 comments on commit 9893f23

Please sign in to comment.