lib/smbclient/Init: throw std::runtime_error on error

This commit is contained in:
Max Kellermann
2016-09-05 11:32:20 +02:00
parent a69c3c1848
commit 135662d6b0
5 changed files with 18 additions and 21 deletions

View File

@@ -28,6 +28,8 @@
#include <libsmbclient.h>
#include <stdexcept>
class SmbclientInputStream final : public InputStream {
SMBCCTX *ctx;
int fd;
@@ -66,10 +68,13 @@ public:
*/
static InputPlugin::InitResult
input_smbclient_init(gcc_unused const ConfigBlock &block, Error &error)
input_smbclient_init(gcc_unused const ConfigBlock &block, gcc_unused Error &error)
{
if (!SmbclientInit(error))
try {
SmbclientInit();
} catch (const std::runtime_error &e) {
return InputPlugin::InitResult::UNAVAILABLE;
}
// TODO: create one global SMBCCTX here?