//
// Copyright (c) PlaceholderCompany. All rights reserved.
//
namespace Jellyfin.Database.Providers.Postgres.Exceptions;
using System;
///
/// Exception thrown when there is a version mismatch between PostgreSQL server and client tools (pg_dump/pg_restore).
///
public class PostgresVersionMismatchException : Exception
{
///
/// Initializes a new instance of the class.
///
/// The PostgreSQL server version.
/// The pg_dump/pg_restore client version.
public PostgresVersionMismatchException(string serverVersion, string clientVersion)
: base(BuildMessage(serverVersion, clientVersion))
{
ServerVersion = serverVersion;
ClientVersion = clientVersion;
}
///
/// Initializes a new instance of the class.
///
/// The PostgreSQL server version.
/// The pg_dump/pg_restore client version.
/// The inner exception.
public PostgresVersionMismatchException(string serverVersion, string clientVersion, Exception innerException)
: base(BuildMessage(serverVersion, clientVersion), innerException)
{
ServerVersion = serverVersion;
ClientVersion = clientVersion;
}
///
/// Gets the PostgreSQL server version.
///
public string ServerVersion { get; }
///
/// Gets the pg_dump/pg_restore client version.
///
public string ClientVersion { get; }
private static string BuildMessage(string serverVersion, string clientVersion)
{
return $"PostgreSQL server version ({serverVersion}) does not match pg_dump version ({clientVersion}). " +
"Please upgrade your PostgreSQL client tools to match or exceed the server version. " +
"You can specify a custom path to pg_dump in the database backup options configuration.";
}
}