using BS.Shared.DataContracts; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BS.Shared.Core { public class AppError { public string Code { get; set; } public string Message { get; set; } public Dictionary Arguments { get; set; } public List InnerErrors { get; set; } public string Displayname => $"AppError {Code}: {Message}"; // Private damit zentral alle Errors private AppError(string code, string message, Dictionary arguments = null, List innerErrors = null) { Code = code; Message = message; Arguments = arguments; InnerErrors = innerErrors; } public AppError() { } // Muster: // - public static readonly AppError Example = new AppError("Code", "Message"); // - Usage: var error = AppError.Example; // Oder mit Abhängigkeit: // - public static Func ExampleFunc = (obj1, obj2, ...) => new AppError(...); // - Usage: var error = AppError.ExampleFunc(obj1, obj2, ...); /// /// Tenant ist in Anfrage null oder unbekannt /// public static AppError MultitenancyOperationTenantUnknown => new AppError("SERV.HLP.10001", "Tenant unbekannt"); /// /// Logger Ordner kann nicht gefunden werden. Hinweis: Web.config /// public static AppError LoggerPathDoNotExist => new AppError("SERV.LOG.10002", "Server falsch konfiguriert"); public static AppError FileNameInvalidChar => new AppError("DATA.LFS.60001", "Fehler beim Speichern"); public static AppError FileNameNotEqFilePath => new AppError("DATA.LFS.60002", "Fehler beim Speichern"); public static AppError StoredFileAlreadyExists => new AppError("DATA.LFS.60003", "Fehler beim Speichern"); public static readonly AppError ApiResponseFailed = new AppError("API.100001", "Api Fehler"); public static readonly AppError JsonParsingError = new AppError("API.100002", "Json Parsing Fehler"); public static readonly Func UnsupportedType = (type) => new AppError("BEW.100001", $"Type nicht implementiert: {type}"); public static readonly Func GkvDatenannahmestelleAdresseNotFound = (dc) => new AppError("GKV.70001", $"Unbekannte Datenannahmestelle. Bitte neu in der Organisation {dc.Name} ermitteln"); } }