10 #pragma clang diagnostic push
11 #pragma clang diagnostic ignored "-Wnullability-extension"
15 #pragma clang diagnostic pop
18namespace Lightweight::Zip
22enum class ZipErrorCode : uint8_t
46 zip_error_t* error = zip_get_error(zip);
49 .libzipError = zip_error_code_zip(error),
50 .message = zip_error_strerror(error),
62 zip_error_init_with_code(&error, errorCode);
63 auto message = std::string(zip_error_strerror(&error));
64 zip_error_fini(&error);
67 .libzipError = errorCode,
82 .message = std::move(msg),
90struct std::formatter<Lightweight::Zip::ZipErrorCode>: std::formatter<std::string_view>
92 auto format(Lightweight::Zip::ZipErrorCode code, format_context& ctx)
const -> format_context::iterator
94 using Lightweight::Zip::ZipErrorCode;
95 std::string_view name;
98 case ZipErrorCode::OpenFailed:
101 case ZipErrorCode::CloseFailed:
102 name =
"CloseFailed";
104 case ZipErrorCode::EntryNotFound:
105 name =
"EntryNotFound";
107 case ZipErrorCode::ReadFailed:
110 case ZipErrorCode::WriteFailed:
111 name =
"WriteFailed";
113 case ZipErrorCode::SourceCreationFailed:
114 name =
"SourceCreationFailed";
117 return std::formatter<std::string_view>::format(name, ctx);
122struct std::formatter<Lightweight::Zip::ZipError>: std::formatter<std::string>
126 return std::formatter<std::string>::format(
127 std::format(
"{}: {} (libzip error: {})", error.code, error.message, error.libzipError), ctx);
Represents an error that occurred during a ZIP operation.
ZipErrorCode code
The error code.
static ZipError FromOpenError(int errorCode, ZipErrorCode code)
std::string message
Human-readable error message.
static ZipError Custom(ZipErrorCode code, std::string msg)
static ZipError FromArchive(zip_t *zip, ZipErrorCode code)
int libzipError
Original libzip error code (0 if not from libzip)