public NngException(NngErrorCode errorCode) { var ptr = NativeMethods.nng_strerror(errorCode); Message = Marshal.PtrToStringAnsi(ptr); ErrorCode = errorCode; }
public void GetMessage(NngErrorCode errorCode, string expectedMessage) { // note: this test does not have any value except to figure out what NNG error code names stand for (as in NNG_ETRANERR) var exception = new NngException(errorCode); Assert.Equal(expectedMessage, exception.Message); }
public static void ThrowIfError(this NngErrorCode errorCode) { switch (errorCode) { case NngErrorCode.Success: return; case NngErrorCode.Unknown: throw new InvalidOperationException("Error code was not set by NNG"); case NngErrorCode.TimedOut: throw new TimeoutException(); default: throw new NngException(errorCode); } }
public static extern IntPtr nng_strerror(NngErrorCode errorCode);