1 /*
2   KeePass Password Safe - The Open-Source Password Manager
3   Copyright (C) 2003-2021 Dominik Reichl <dominik.reichl@t-online.de>
4 
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 2 of the License, or
8   (at your option) any later version.
9 
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14 
15   You should have received a copy of the GNU General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19 
20 using System;
21 using System.Collections.Generic;
22 using System.Text;
23 
24 using KeePassLib.Resources;
25 using KeePassLib.Utility;
26 
27 namespace KeePassLib.Serialization
28 {
29 	public sealed class OldFormatException : Exception
30 	{
31 		private string m_strFormat = string.Empty;
32 		private OldFormatType m_type = OldFormatType.Unknown;
33 
34 		public enum OldFormatType
35 		{
36 			Unknown = 0,
37 			KeePass1x = 1
38 		}
39 
40 		public override string Message
41 		{
42 			get
43 			{
44 				string str = KLRes.OldFormat + ((m_strFormat.Length > 0) ?
45 					(@" (" + m_strFormat + @")") : string.Empty) + ".";
46 
47 				if(m_type == OldFormatType.KeePass1x)
48 					str += MessageService.NewParagraph + KLRes.KeePass1xHint;
49 
50 				return str;
51 			}
52 		}
53 
OldFormatException(string strFormatName)54 		public OldFormatException(string strFormatName)
55 		{
56 			if(strFormatName != null) m_strFormat = strFormatName;
57 		}
58 
OldFormatException(string strFormatName, OldFormatType t)59 		public OldFormatException(string strFormatName, OldFormatType t)
60 		{
61 			if(strFormatName != null) m_strFormat = strFormatName;
62 
63 			m_type = t;
64 		}
65 	}
66 }
67