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