Besser nachvollziehbare Exception
This commit is contained in:
12
Jugenddienst Stunden/Exceptions/NoDataException.cs
Normal file
12
Jugenddienst Stunden/Exceptions/NoDataException.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Jugenddienst_Stunden.Exceptions;
|
||||
public class NoDataException : Exception {
|
||||
public NoDataException() : base("Keine Daten gefunden") { }
|
||||
public NoDataException(string message) : base(message) { }
|
||||
public NoDataException(string message, Exception inner) : base(message, inner) { }
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using Jugenddienst_Stunden.Types;
|
||||
using System.Collections.ObjectModel;
|
||||
using Jugenddienst_Stunden.Exceptions;
|
||||
|
||||
namespace Jugenddienst_Stunden.Models;
|
||||
|
||||
@@ -112,13 +113,13 @@ internal class Stunde : ObservableObject {
|
||||
string? data = await Auth.GetApiDataWithAuthAsync(tokendata.url + "?date=" + date.ToString("yyyy-MM-dd"), tokendata.apiKey);
|
||||
|
||||
if (data == "null") {
|
||||
throw new Exception("Keine Daten für " + date.ToString("ddd. dd. MMM") + " erhalten");
|
||||
throw new NoDataException("Keine Daten für " + date.ToString("ddd. dd. MMM") + " erhalten");
|
||||
}
|
||||
if (data == "\"Lalala\"") {
|
||||
throw new Exception("Problem mit Token");
|
||||
}
|
||||
if (data == null) {
|
||||
throw new Exception("Keine Daten erhalten");
|
||||
throw new NoDataException("Keine Daten erhalten");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user