Browse Source

Better error handling for internal clients

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2189 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 17 years ago
parent
commit
3e27cf309e
2 changed files with 34 additions and 1 deletions
  1. +1
    -1
      common/JackInternalClient.cpp
  2. +33
    -0
      common/JackInternalClient.h

+ 1
- 1
common/JackInternalClient.cpp View File

@@ -135,7 +135,7 @@ JackLoadableInternalClient::JackLoadableInternalClient(JackServer* server, JackS
jack_log("JackLoadableInternalClient::JackLoadableInternalClient path_to_so = %s", path_to_so);

if (fHandle == 0) {
jack_error("error loading %s", so_name);
PrintLoadError(so_name);
throw - 1;
}



+ 33
- 0
common/JackInternalClient.h View File

@@ -67,6 +67,38 @@ class JackInternalClient : public JackClient
#define UnloadJackModule(handle) FreeLibrary((handle));
#define GetJackProc(handle, name) GetProcAddress((handle), (name));

void PrintLoadError(const char* so_name)
{
// Retrieve the system error message for the last-error code

LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
DWORD dw = GetLastError();

FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );

// Display the error message and exit the process

lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
(lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)lpszFunction)+40)*sizeof(TCHAR));
StringCchPrintf((LPTSTR)lpDisplayBuf,
LocalSize(lpDisplayBuf) / sizeof(TCHAR),
TEXT("error loading %s err = %s"), so_name, lpMsgBuf);
jack_error((LPCTSTR)lpDisplayBuf);

LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);
}

#else

#include <dlfcn.h>
@@ -74,6 +106,7 @@ class JackInternalClient : public JackClient
#define LoadJackModule(name) dlopen((name), RTLD_NOW | RTLD_LOCAL);
#define UnloadJackModule(handle) dlclose((handle));
#define GetJackProc(handle, name) dlsym((handle), (name));
#define PrintLoadError(so_name) jack_log("error loading %s err = %s", so_name, dlerror());

#endif



Loading…
Cancel
Save