Skip to content

Commit

Permalink
Merge pull request #46 from David032/32-exception-handling
Browse files Browse the repository at this point in the history
32 Exception Handling
  • Loading branch information
David032 authored Feb 12, 2024
2 parents e8f5c18 + 2b78d67 commit 72711d5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
5 changes: 3 additions & 2 deletions skullOS.Modules/Adventure.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using skullOS.Core;
using skullOS.HardwareServices;
using skullOS.HardwareServices.Interfaces;
using skullOS.Modules.Exceptions;
using skullOS.Modules.Interfaces;
using Timer = System.Timers.Timer;

Expand Down Expand Up @@ -34,12 +35,12 @@ private void TakePicture_Elapsed(object? sender, System.Timers.ElapsedEventArgs

public override void OnAction(object? sender, EventArgs e)
{
throw new NotImplementedException();
throw new OnActionException("Adventure does not support OnAction");
}

public override void OnEnable(string[] args)
{
throw new NotImplementedException();
throw new OnEnableException("Adventure does not support OnEnable");
}

public override string ToString()
Expand Down
5 changes: 3 additions & 2 deletions skullOS.Modules/Buzzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using skullOS.HardwareServices;
using skullOS.Modules.Exceptions;
using skullOS.Modules.Interfaces;
using static skullOS.Modules.BuzzerLibrary;
using static skullOS.Modules.BuzzerStructures;
Expand Down Expand Up @@ -34,11 +35,11 @@ public void PlayTune(Tunes tuneToPlay)

public override void OnAction(object? sender, EventArgs e)
{
throw new NotImplementedException();
throw new OnActionException("Buzzer does not support OnAction");
}
public override void OnEnable(string[] args)
{
throw new NotImplementedException();
throw new OnEnableException("Buzzer does not support OnEnable");
}
public override string ToString()
{
Expand Down
6 changes: 6 additions & 0 deletions skullOS.Modules/Exceptions/OnActionException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace skullOS.Modules.Exceptions
{
public class OnActionException(string message) : Exception(message)
{
}
}
6 changes: 6 additions & 0 deletions skullOS.Modules/Exceptions/OnEnableException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace skullOS.Modules.Exceptions
{
public class OnEnableException(string message) : Exception(message)
{
}
}
5 changes: 3 additions & 2 deletions skullOS.Modules/Prop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using skullOS.Core;
using skullOS.HardwareServices;
using skullOS.HardwareServices.Interfaces;
using skullOS.Modules.Exceptions;
using System.Device.Pwm.Drivers;
using Timer = System.Timers.Timer;

Expand Down Expand Up @@ -102,12 +103,12 @@ private async void FlapEar(bool useLeft = true)

public override void OnAction(object? sender, EventArgs e)
{
throw new NotImplementedException();
throw new OnActionException("Prop doesn't support OnAction");
}

public override void OnEnable(string[] args)
{
throw new NotImplementedException();
throw new OnEnableException("Prop doesn't support OnEnable");
}
public override string ToString()
{
Expand Down
5 changes: 3 additions & 2 deletions skullOS.Modules/Support.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using skullOS.HardwareServices;
using skullOS.HardwareServices.Interfaces;
using skullOS.Modules.Exceptions;
using skullOS.Modules.Interfaces;
using System.Device.Gpio;
using Timer = System.Timers.Timer;
Expand Down Expand Up @@ -42,12 +43,12 @@ private void LowBatteryAlert_Elapsed(object? sender, System.Timers.ElapsedEventA

public override void OnAction(object? sender, EventArgs e)
{
throw new NotImplementedException();
throw new OnActionException("Support doesn't support OnAction");
}

public override void OnEnable(string[] args)
{
throw new NotImplementedException();
throw new OnEnableException("Support doesn't support OnEnable");
}

public override string ToString()
Expand Down

0 comments on commit 72711d5

Please sign in to comment.