Commit 9ab19972 authored by Brickner_cp's avatar Brickner_cp

Better errors in Core

parent 3e1b443e
......@@ -26,3 +26,12 @@ array<Byte>^ MarshalingServices::UnamangedToManagedByteArray(const unsigned char
Marshal::Copy((IntPtr)const_cast<unsigned char*>(unmanagedByteArray), managedBytes, offset, count);
return managedBytes;
}
/*
// static
System::String^ MarshalingServices::UnmangedToManagedString(const std::string& unmanagedString)
{
array<Byte>^ managedBytes = UnamangedToManagedByteArray(reinterpret_cast<const unsigned char*>(unmanagedString.c_str()), 0, (int)unmanagedString.length());
return System::Text::Encoding::ASCII->GetString(managedBytes);
}
*/
\ No newline at end of file
......@@ -10,6 +10,7 @@ namespace PcapDotNet { namespace Core
static std::string ManagedToUnmanagedString(System::String^ managedString);
static array<System::Byte>^ UnamangedToManagedByteArray(const unsigned char* unmanagedByteArray, int offset, int count);
// static System::String^ UnmangedToManagedString(const std::string& unmanagedString);
private:
[System::Diagnostics::DebuggerNonUserCode]
......
......@@ -296,6 +296,7 @@ PacketCommunicator::PacketCommunicator(const char* source, int snapshotLength, P
if (pcapDescriptor == NULL)
{
throw gcnew InvalidOperationException("Unable to open the adapter. " + gcnew String(source) + " is not supported by WinPcap");
// throw gcnew InvalidOperationException("Unable to open the adapter. " + gcnew String(source) + " is not supported by WinPcap. Error: " + MarshalingServices::UnmangedToManagedString(std::string(errbuf)));
}
_pcapDescriptor = pcapDescriptor;
......
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