archive/zzip: improve error reporting
Most importantly, this commit translates ZZIP_ENOENT to std::system_error(ENOENT) so IsFileNotFound() returns true and find_stream_art() can suppress the log line.
This commit is contained in:
parent
ce093be12c
commit
32799ff682
2
NEWS
2
NEWS
@ -1,4 +1,6 @@
|
|||||||
ver 0.21.17 (not yet released)
|
ver 0.21.17 (not yet released)
|
||||||
|
* archive
|
||||||
|
- zzip: improve error reporting
|
||||||
* outputs
|
* outputs
|
||||||
- jack: mark ports as terminal
|
- jack: mark ports as terminal
|
||||||
- shout: declare metadata as UTF-8
|
- shout: declare metadata as UTF-8
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2018 The Music Player Daemon Project
|
* Copyright 2003-2019 The Music Player Daemon Project
|
||||||
* http://www.musicpd.org
|
* http://www.musicpd.org
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -27,6 +27,7 @@
|
|||||||
#include "../ArchiveVisitor.hxx"
|
#include "../ArchiveVisitor.hxx"
|
||||||
#include "input/InputStream.hxx"
|
#include "input/InputStream.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
|
#include "system/Error.hxx"
|
||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
|
|
||||||
#include <zzip/zzip.h>
|
#include <zzip/zzip.h>
|
||||||
@ -120,10 +121,20 @@ ZzipArchiveFile::OpenStream(const char *pathname,
|
|||||||
Mutex &mutex)
|
Mutex &mutex)
|
||||||
{
|
{
|
||||||
ZZIP_FILE *_file = zzip_file_open(dir->dir, pathname, 0);
|
ZZIP_FILE *_file = zzip_file_open(dir->dir, pathname, 0);
|
||||||
if (_file == nullptr)
|
if (_file == nullptr) {
|
||||||
throw FormatRuntimeError("not found in the ZIP file: %s",
|
const auto error = (zzip_error_t)zzip_error(dir->dir);
|
||||||
|
switch (error) {
|
||||||
|
case ZZIP_ENOENT:
|
||||||
|
throw FormatFileNotFound("Failed to open '%s' in ZIP file",
|
||||||
pathname);
|
pathname);
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw FormatRuntimeError("Failed to open '%s' in ZIP file: %s",
|
||||||
|
pathname,
|
||||||
|
zzip_strerror(error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return std::make_unique<ZzipInputStream>(dir, pathname,
|
return std::make_unique<ZzipInputStream>(dir, pathname,
|
||||||
mutex,
|
mutex,
|
||||||
_file);
|
_file);
|
||||||
|
Loading…
Reference in New Issue
Block a user