private static string GetErrorText(LzError error) { switch (error) { case LzError.BadInHandle: return("Invalid input handle."); case LzError.BadOutHandle: return("Invalid output handle."); case LzError.Read: return("Corrupt compressed file format."); case LzError.Write: return("Out of space for output file."); case LzError.GlobalAlloc: return("Insufficient memory."); case LzError.GlobalLock: return("Bad global handle."); case LzError.BadValue: return("Input parameter out of acceptable range."); case LzError.UnknownAlgorithm: return("Compression algorithm not recognized."); default: return(error.ToString()); } }
private static string GetErrorText(LzError error) { return(error switch { LzError.BadInHandle => "Invalid input handle.", LzError.BadOutHandle => "Invalid output handle.", LzError.Read => "Corrupt compressed file format.", LzError.Write => "Out of space for output file.", LzError.GlobalAlloc => "Insufficient memory.", LzError.GlobalLock => "Bad global handle.", LzError.BadValue => "Input parameter out of acceptable range.", LzError.UnknownAlgorithm => "Compression algorithm not recognized.", _ => error.ToString(), });
public LzException(LzError error, string?path = null) : base(GetMessage(error, path), Errors.HResult.E_FAIL) { Error = error; }
private static string GetMessage(LzError error, string?path) { return(path == null ? $"{GetErrorText(error)}" : $"{GetErrorText(error)} '{path}'"); }
public LzException(LzError error, string path = null) : base(GetMessage(error, path), HRESULT.E_FAIL) { Error = error; }