diff --git a/BUILDS/net5.0/MusicCommands.dll b/BUILDS/net5.0/MusicCommands.dll index 06a3e2a..75145c3 100644 Binary files a/BUILDS/net5.0/MusicCommands.dll and b/BUILDS/net5.0/MusicCommands.dll differ diff --git a/BUILDS/net5.0/PluginManager.dll b/BUILDS/net5.0/PluginManager.dll index ebac89d..cb30dc9 100644 Binary files a/BUILDS/net5.0/PluginManager.dll and b/BUILDS/net5.0/PluginManager.dll differ diff --git a/MusicCommands/LinkMusic.cs b/MusicCommands/LinkMusic.cs index bf040cc..32fc6bf 100644 --- a/MusicCommands/LinkMusic.cs +++ b/MusicCommands/LinkMusic.cs @@ -1,4 +1,6 @@ -using System; +using PluginManager.Others.Exceptions; + +using System; using System.IO; using System.Net; using System.Threading.Tasks; @@ -22,8 +24,8 @@ namespace MusicCommands private async Task GetYoutubeVideoID() { - //https://www.youtube.com/watch?v=i-p--m7qaCM&ab_channel=Leviathan - return URL.Split("=")[1].Split('&')[0]; + //https://www.youtube.com/watch?v=i-p--m7qaCM&ab_channel={channel}/ + return URL.Split('=')[1].Split('&')[0]; } public async Task GetStream() @@ -32,13 +34,18 @@ namespace MusicCommands if (type == LinkType.SPOTIFY) s = await GetSpotifyMusicStreamAsync(); else if (type == LinkType.YOUTUBE) s = await GetYoutubeMusicStreamAsync(); else s = await GetRAWMusicStreamAsync(); + if (s == null) + { + Console.WriteLine("Failed to get the stream for url: " + this.URL); + throw new APIException("URL [" + this.URL + "] is invalid", "async Task GetStream()", "Work in progress", PluginManager.Others.Error.STREAM_NOT_FOUND); + } return s; } private async Task GetSpotifyMusicStreamAsync() { - Stream response = null; - return response; + throw new APIException("Not implemented", "async Task GetSpotifyMusicStream()", + "Work in progress", PluginManager.Others.Error.STREAM_NOT_FOUND); } private async Task GetYoutubeMusicStreamAsync() diff --git a/PluginManager/Others/Enums.cs b/PluginManager/Others/Enums.cs index 90d89a4..43cb702 100644 --- a/PluginManager/Others/Enums.cs +++ b/PluginManager/Others/Enums.cs @@ -8,7 +8,7 @@ { WINDOWS, LINUX, MAC_OS, UNKNOWN } public enum Error - { UNKNOWN_ERROR, GUILD_NOT_FOUND, } + { UNKNOWN_ERROR, GUILD_NOT_FOUND, STREAM_NOT_FOUND } public enum OutputLogLevel { NONE, INFO, WARNING, ERROR, CRITICAL } } \ No newline at end of file diff --git a/PluginManager/Others/Exceptions/APIException.cs b/PluginManager/Others/Exceptions/APIException.cs index 34d6b48..ac9c895 100644 --- a/PluginManager/Others/Exceptions/APIException.cs +++ b/PluginManager/Others/Exceptions/APIException.cs @@ -2,11 +2,19 @@ using System; namespace PluginManager.Others.Exceptions { - [System.Serializable] + [Serializable] public class APIException : Exception { - public string? Function { get; } - public Error? ErrorCode { get; } + public string? Function { get; } = "not specified"; + public Error? ErrorCode { get; } = Error.UNKNOWN_ERROR; + public string? PossibleCause { get; } = "not specified"; + + public APIException(string message, string? function, string possible_cause, Error error) : base(message) + { + ErrorCode = error; + Function = function; + PossibleCause = possible_cause; + } public APIException(string message, string? function, Error? errorCode) : base(message) { @@ -16,14 +24,12 @@ namespace PluginManager.Others.Exceptions public APIException(string message, string? function) : base(message) { - ErrorCode = Error.UNKNOWN_ERROR; Function = function; } public APIException(string message) : base(message) { - ErrorCode = Error.UNKNOWN_ERROR; - Function = "Unspecified_Function"; + } public void Print() @@ -31,6 +37,9 @@ namespace PluginManager.Others.Exceptions Console.WriteLine("Message Content: " + Message); Console.WriteLine("Function: " + Function); Console.WriteLine("Error Code: " + ErrorCode.ToString()); + Console.WriteLine("Possible cause: " + PossibleCause); + if (this.StackTrace != null) + Functions.WriteErrFile(this.StackTrace); } }