diff --git a/src/Audio/AudioDevice.cs b/src/Audio/AudioDevice.cs index 0ced362..410cec8 100644 --- a/src/Audio/AudioDevice.cs +++ b/src/Audio/AudioDevice.cs @@ -58,7 +58,7 @@ namespace Microsoft.Xna.Framework.Audio // We should only have one of these! if (ALDevice != null) { - System.Console.WriteLine("ALDevice already exists, overwriting!"); + FNAPlatform.Log("ALDevice already exists, overwriting!"); } bool disableSound = Environment.GetEnvironmentVariable( diff --git a/src/Audio/Cue.cs b/src/Audio/Cue.cs index 991bfc4..e19d0e5 100644 --- a/src/Audio/Cue.cs +++ b/src/Audio/Cue.cs @@ -306,7 +306,7 @@ namespace Microsoft.Xna.Framework.Audio return curVar.GetValue(); } } - throw new Exception("Instance variable not found!"); + throw new ArgumentException("Instance variable not found!"); } public void Pause() @@ -338,7 +338,7 @@ namespace Microsoft.Xna.Framework.Audio } else if (INTERNAL_data.MaxCueBehavior == MaxInstanceBehavior.Queue) { - throw new Exception("Cue Queueing not handled!"); + throw new NotImplementedException("Cue Queueing not handled!"); } else if (INTERNAL_data.MaxCueBehavior == MaxInstanceBehavior.ReplaceOldest) { @@ -414,7 +414,7 @@ namespace Microsoft.Xna.Framework.Audio return; } } - throw new Exception("Instance variable not found!"); + throw new ArgumentException("Instance variable not found!"); } public void Stop(AudioStopOptions options) @@ -483,7 +483,7 @@ namespace Microsoft.Xna.Framework.Audio } else { - throw new Exception("Unhandled XACTEvent type!"); + throw new NotImplementedException("Unhandled XACTEvent type!"); } INTERNAL_eventPlayed[i] = true; } @@ -699,7 +699,7 @@ namespace Microsoft.Xna.Framework.Audio } else { - throw new Exception("RPC Parameter Type: " + curRPC.Parameter.ToString()); + throw new NotImplementedException("RPC Parameter Type: " + curRPC.Parameter.ToString()); } } } diff --git a/src/Audio/CueData.cs b/src/Audio/CueData.cs index 830b60f..e3cc199 100644 --- a/src/Audio/CueData.cs +++ b/src/Audio/CueData.cs @@ -718,7 +718,7 @@ namespace Microsoft.Xna.Framework.Audio * Type 9 - Marker Event * -flibit */ - throw new Exception( + throw new NotImplementedException( "EVENT TYPE " + eventType.ToString() + " NOT IMPLEMENTED!" ); } @@ -931,7 +931,7 @@ namespace Microsoft.Xna.Framework.Audio } else { - throw new Exception( + throw new NotImplementedException( "Variation Playlist Type unhandled: " + INTERNAL_variationType.ToString() ); diff --git a/src/Audio/DynamicSoundEffectInstance.cs b/src/Audio/DynamicSoundEffectInstance.cs index 637528e..09d9b92 100644 --- a/src/Audio/DynamicSoundEffectInstance.cs +++ b/src/Audio/DynamicSoundEffectInstance.cs @@ -226,7 +226,7 @@ namespace Microsoft.Xna.Framework.Audio INTERNAL_alSource = AudioDevice.ALDevice.GenSource(); if (INTERNAL_alSource == null) { - System.Console.WriteLine("WARNING: AL SOURCE WAS NOT AVAILABLE. SKIPPING."); + FNAPlatform.Log("WARNING: AL SOURCE WAS NOT AVAILABLE. SKIPPING."); return; } diff --git a/src/Audio/OpenALDevice.cs b/src/Audio/OpenALDevice.cs index 6c2e016..5489fd2 100644 --- a/src/Audio/OpenALDevice.cs +++ b/src/Audio/OpenALDevice.cs @@ -132,7 +132,7 @@ namespace Microsoft.Xna.Framework.Audio alDevice = ALC10.alcOpenDevice(envDevice); if (CheckALCError() || alDevice == IntPtr.Zero) { - throw new Exception("Could not open audio device!"); + throw new InvalidOperationException("Could not open audio device!"); } int[] attribute = new int[0]; @@ -140,14 +140,14 @@ namespace Microsoft.Xna.Framework.Audio if (CheckALCError() || alContext == IntPtr.Zero) { Dispose(); - throw new Exception("Could not create OpenAL context"); + throw new InvalidOperationException("Could not create OpenAL context"); } ALC10.alcMakeContextCurrent(alContext); if (CheckALCError()) { Dispose(); - throw new Exception("Could not make OpenAL context current"); + throw new InvalidOperationException("Could not make OpenAL context current"); } float[] ori = new float[] @@ -526,7 +526,7 @@ namespace Microsoft.Xna.Framework.Audio */ if (clamp && (pitch < -1.0f || pitch > 1.0f)) { - throw new Exception("XNA PITCH MUST BE WITHIN [-1.0f, 1.0f]!"); + throw new IndexOutOfRangeException("XNA PITCH MUST BE WITHIN [-1.0f, 1.0f]!"); } AL10.alSourcef( (source as OpenALSource).Handle, @@ -629,7 +629,7 @@ namespace Microsoft.Xna.Framework.Audio { if (bufs[i] != (sync[i] as OpenALBuffer).Handle) { - throw new Exception("Buffer desync!"); + throw new InvalidOperationException("Buffer desync!"); } } #endif @@ -1108,7 +1108,7 @@ namespace Microsoft.Xna.Framework.Audio return; } - System.Console.WriteLine("OpenAL Error: {0:X}", err); + FNAPlatform.Log("OpenAL Error: " + err.ToString("X4")); #if VERBOSE_AL_DEBUGGING throw new InvalidOperationException("OpenAL Error!"); #endif @@ -1123,7 +1123,7 @@ namespace Microsoft.Xna.Framework.Audio return false; } - System.Console.WriteLine("OpenAL Device Error: {0:X}", err); + FNAPlatform.Log("OpenAL Device Error: " + err.ToString("X4")); return true; } diff --git a/src/Audio/SoundEffectInstance.cs b/src/Audio/SoundEffectInstance.cs index 3164625..7b9e593 100644 --- a/src/Audio/SoundEffectInstance.cs +++ b/src/Audio/SoundEffectInstance.cs @@ -264,7 +264,7 @@ namespace Microsoft.Xna.Framework.Audio ); if (INTERNAL_alSource == null) { - System.Console.WriteLine("WARNING: AL SOURCE WAS NOT AVAILABLE. SKIPPING."); + FNAPlatform.Log("WARNING: AL SOURCE WAS NOT AVAILABLE. SKIPPING."); return; } diff --git a/src/Audio/XACTInternal.cs b/src/Audio/XACTInternal.cs index 3dc0e16..ca460f5 100644 --- a/src/Audio/XACTInternal.cs +++ b/src/Audio/XACTInternal.cs @@ -459,7 +459,7 @@ namespace Microsoft.Xna.Framework.Audio } else { - throw new Exception("DSP parameter unhandled: " + index.ToString()); + throw new NotImplementedException("DSP parameter unhandled: " + index.ToString()); } } } diff --git a/src/Graphics/Effect/Effect.cs b/src/Graphics/Effect/Effect.cs index 67d11d6..7228812 100644 --- a/src/Graphics/Effect/Effect.cs +++ b/src/Graphics/Effect/Effect.cs @@ -671,7 +671,7 @@ namespace Microsoft.Xna.Framework.Graphics } else { - throw new Exception("Unhandled render state!"); + throw new NotImplementedException("Unhandled render state!"); } } if (blendStateChanged) @@ -886,7 +886,7 @@ namespace Microsoft.Xna.Framework.Graphics } else { - throw new Exception("Unhandled sampler state!"); + throw new NotImplementedException("Unhandled sampler state!"); } } if (filterChanged) diff --git a/src/Graphics/GraphicsDevice.cs b/src/Graphics/GraphicsDevice.cs index 46f9914..c8514ea 100644 --- a/src/Graphics/GraphicsDevice.cs +++ b/src/Graphics/GraphicsDevice.cs @@ -424,12 +424,12 @@ namespace Microsoft.Xna.Framework.Graphics wiiuStream = DRC.drc_new_streamer(); if (wiiuStream == IntPtr.Zero) { - System.Console.WriteLine("Failed to alloc GamePad stream!"); + FNAPlatform.Log("Failed to alloc GamePad stream!"); return; } if (DRC.drc_start_streamer(wiiuStream) < 1) // ??? { - System.Console.WriteLine("Failed to start GamePad stream!"); + FNAPlatform.Log("Failed to start GamePad stream!"); DRC.drc_delete_streamer(wiiuStream); wiiuStream = IntPtr.Zero; return; diff --git a/src/Graphics/OpenGLDevice.cs b/src/Graphics/OpenGLDevice.cs index 9cd10a7..e516314 100644 --- a/src/Graphics/OpenGLDevice.cs +++ b/src/Graphics/OpenGLDevice.cs @@ -635,10 +635,10 @@ namespace Microsoft.Xna.Framework.Graphics MojoShader.MOJOSHADER_glMakeContextCurrent(shaderContext); // Print GL information - System.Console.WriteLine("OpenGL Device: " + glGetString(GLenum.GL_RENDERER)); - System.Console.WriteLine("OpenGL Driver: " + glGetString(GLenum.GL_VERSION)); - System.Console.WriteLine("OpenGL Vendor: " + glGetString(GLenum.GL_VENDOR)); - System.Console.WriteLine("MojoShader Profile: " + shaderProfile); + FNAPlatform.Log("OpenGL Device: " + glGetString(GLenum.GL_RENDERER)); + FNAPlatform.Log("OpenGL Driver: " + glGetString(GLenum.GL_VERSION)); + FNAPlatform.Log("OpenGL Vendor: " + glGetString(GLenum.GL_VENDOR)); + FNAPlatform.Log("MojoShader Profile: " + shaderProfile); // Load the extension list, initialize extension-dependent components string extensions; @@ -1788,7 +1788,9 @@ namespace Microsoft.Xna.Framework.Graphics glEffect = MojoShader.MOJOSHADER_glCompileEffect(effect); if (glEffect == IntPtr.Zero) { - throw new Exception(MojoShader.MOJOSHADER_glGetError()); + throw new InvalidOperationException( + MojoShader.MOJOSHADER_glGetError() + ); } #if !DISABLE_THREADING @@ -1826,7 +1828,9 @@ namespace Microsoft.Xna.Framework.Graphics glEffect = MojoShader.MOJOSHADER_glCompileEffect(effect); if (glEffect == IntPtr.Zero) { - throw new Exception(MojoShader.MOJOSHADER_glGetError()); + throw new InvalidOperationException( + MojoShader.MOJOSHADER_glGetError() + ); } #if !DISABLE_THREADING diff --git a/src/Graphics/OpenGLDevice_GL.cs b/src/Graphics/OpenGLDevice_GL.cs index bceba72..b60973d 100644 --- a/src/Graphics/OpenGLDevice_GL.cs +++ b/src/Graphics/OpenGLDevice_GL.cs @@ -822,7 +822,7 @@ namespace Microsoft.Xna.Framework.Graphics IntPtr message, // const GLchar* IntPtr userParam // const GLvoid* ) { - System.Console.WriteLine( + FNAPlatform.Log( "{0}\n\tSource: {1}\n\tType: {2}\n\tSeverity: {3}", Marshal.PtrToStringAnsi(message), source.ToString(), @@ -831,7 +831,7 @@ namespace Microsoft.Xna.Framework.Graphics ); if (type == GLenum.GL_DEBUG_TYPE_ERROR_ARB) { - throw new Exception("ARB_debug_output found an error."); + throw new InvalidOperationException("ARB_debug_output found an error."); } } @@ -1213,7 +1213,7 @@ namespace Microsoft.Xna.Framework.Graphics { if (useES2) { - System.Console.WriteLine("Some non-ES functions failed to load. Beware..."); + FNAPlatform.Log("Some non-ES functions failed to load. Beware..."); } else { @@ -1366,7 +1366,7 @@ namespace Microsoft.Xna.Framework.Graphics IntPtr messageControl = SDL.SDL_GL_GetProcAddress("glDebugMessageControlARB"); if (messageCallback == IntPtr.Zero || messageControl == IntPtr.Zero) { - System.Console.WriteLine("ARB_debug_output not supported!"); + FNAPlatform.Log("ARB_debug_output not supported!"); } else { @@ -1409,7 +1409,7 @@ namespace Microsoft.Xna.Framework.Graphics IntPtr stringMarkerCallback = SDL.SDL_GL_GetProcAddress("glStringMarkerGREMEDY"); if (stringMarkerCallback == IntPtr.Zero) { - System.Console.WriteLine("GREMEDY_string_marker not supported!"); + FNAPlatform.Log("GREMEDY_string_marker not supported!"); } else { diff --git a/src/Graphics/Vertices/VertexDeclaration.cs b/src/Graphics/Vertices/VertexDeclaration.cs index fcea81a..9638516 100644 --- a/src/Graphics/Vertices/VertexDeclaration.cs +++ b/src/Graphics/Vertices/VertexDeclaration.cs @@ -95,7 +95,7 @@ namespace Microsoft.Xna.Framework.Graphics VertexDeclaration vertexDeclaration = type.VertexDeclaration; if (vertexDeclaration == null) { - throw new Exception("VertexDeclaration cannot be null"); + throw new ArgumentException("vertexType's VertexDeclaration cannot be null"); } return vertexDeclaration; diff --git a/src/Media/Xiph/Song.cs b/src/Media/Xiph/Song.cs index 8261cf5..faa3a49 100644 --- a/src/Media/Xiph/Song.cs +++ b/src/Media/Xiph/Song.cs @@ -207,7 +207,7 @@ namespace Microsoft.Xna.Framework.Media */ if (Math.Abs(Duration.Milliseconds - durationMS) > 1000) { - throw new Exception("XNB/OGG duration mismatch!"); + throw new InvalidOperationException("XNB/OGG duration mismatch!"); } } diff --git a/src/Media/Xiph/Video.cs b/src/Media/Xiph/Video.cs index 9d54354..3295f88 100644 --- a/src/Media/Xiph/Video.cs +++ b/src/Media/Xiph/Video.cs @@ -117,11 +117,11 @@ namespace Microsoft.Xna.Framework.Media */ if (width != Width || height != Height) { - throw new Exception("XNB/OGV width/height mismatch!"); + throw new InvalidOperationException("XNB/OGV width/height mismatch!"); } if (Math.Abs(FramesPerSecond - framesPerSecond) >= 1.0f) { - throw new Exception("XNB/OGV framesPerSecond mismatch!"); + throw new InvalidOperationException("XNB/OGV framesPerSecond mismatch!"); } // FIXME: Oh, hey! I wish we had this info in TheoraPlay! diff --git a/src/Media/Xiph/VideoPlayer.cs b/src/Media/Xiph/VideoPlayer.cs index faf2bf4..6c62f30 100644 --- a/src/Media/Xiph/VideoPlayer.cs +++ b/src/Media/Xiph/VideoPlayer.cs @@ -638,13 +638,13 @@ namespace Microsoft.Xna.Framework.Media } // Initialize the thread! - System.Console.Write("Starting Theora player..."); + FNAPlatform.Log("Starting Theora player..."); timer.Start(); if (audioStream != null) { audioStream.Play(); } - System.Console.WriteLine(" Done!"); + FNAPlatform.Log("Started!"); } public void Stop() @@ -661,7 +661,7 @@ namespace Microsoft.Xna.Framework.Media State = MediaState.Stopped; // Wait for the player to end if it's still going. - System.Console.Write("Signaled Theora player to stop, waiting..."); + FNAPlatform.Log("Signaled Theora player to stop, waiting..."); timer.Stop(); timer.Reset(); if (audioStream != null) @@ -676,7 +676,7 @@ namespace Microsoft.Xna.Framework.Media } Video.AttachedToPlayer = false; Video.Dispose(); - System.Console.WriteLine(" Done!"); + FNAPlatform.Log("Stopped!"); } public void Pause() diff --git a/src/SDL2/SDL2_FNAPlatform.cs b/src/SDL2/SDL2_FNAPlatform.cs index 7c079f7..7374886 100644 --- a/src/SDL2/SDL2_FNAPlatform.cs +++ b/src/SDL2/SDL2_FNAPlatform.cs @@ -451,7 +451,7 @@ namespace Microsoft.Xna.Framework } catch(DllNotFoundException e) { - System.Console.WriteLine("OpenAL not found! Need FNA.dll.config?"); + Log("OpenAL not found! Need FNA.dll.config?"); throw e; } catch(Exception) @@ -476,11 +476,11 @@ namespace Microsoft.Xna.Framework { if (SDL.SDL_GL_SetSwapInterval(-1) != -1) { - System.Console.WriteLine("Using EXT_swap_control_tear VSync!"); + Log("Using EXT_swap_control_tear VSync!"); } else { - System.Console.WriteLine("EXT_swap_control_tear unsupported. Fall back to standard VSync."); + Log("EXT_swap_control_tear unsupported. Fall back to standard VSync."); SDL.SDL_ClearError(); SDL.SDL_GL_SetSwapInterval(1); } @@ -496,7 +496,7 @@ namespace Microsoft.Xna.Framework } else { - throw new Exception("Unrecognized PresentInterval!"); + throw new NotSupportedException("Unrecognized PresentInterval!"); } } @@ -1251,7 +1251,7 @@ namespace Microsoft.Xna.Framework INTERNAL_haptics[which] = SDL.SDL_HapticOpenFromJoystick(thisJoystick); if (INTERNAL_haptics[which] == IntPtr.Zero) { - System.Console.WriteLine("HAPTIC OPEN ERROR: " + SDL.SDL_GetError()); + Log("HAPTIC OPEN ERROR: " + SDL.SDL_GetError()); } } if (INTERNAL_haptics[which] != IntPtr.Zero) @@ -1406,7 +1406,7 @@ namespace Microsoft.Xna.Framework } // Print controller information to stdout. - System.Console.WriteLine( + Log( "Controller " + which.ToString() + ": " + SDL.SDL_GameControllerName(INTERNAL_devices[which]) ); @@ -1434,7 +1434,7 @@ namespace Microsoft.Xna.Framework // A lot of errors can happen here, but honestly, they can be ignored... SDL.SDL_ClearError(); - System.Console.WriteLine("Removed device, player: " + output.ToString()); + Log("Removed device, player: " + output.ToString()); } // GetState can convert stick values to button values diff --git a/src/SDL2/SDL2_KeyboardUtil.cs b/src/SDL2/SDL2_KeyboardUtil.cs index 0d18b8d..555bdaf 100644 --- a/src/SDL2/SDL2_KeyboardUtil.cs +++ b/src/SDL2/SDL2_KeyboardUtil.cs @@ -418,7 +418,7 @@ namespace Microsoft.Xna.Framework.Input } else { - System.Console.WriteLine("KEY MISSING FROM SDL2->XNA DICTIONARY: " + key.ToString()); + SDL2_FNAPlatform.Log("KEY MISSING FROM SDL2->XNA DICTIONARY: " + key.ToString()); return Keys.None; } } @@ -432,7 +432,7 @@ namespace Microsoft.Xna.Framework.Input } else { - System.Console.WriteLine("SCANCODE MISSING FROM SDL2->XNA DICTIONARY: " + key.ToString()); + SDL2_FNAPlatform.Log("SCANCODE MISSING FROM SDL2->XNA DICTIONARY: " + key.ToString()); return Keys.None; } } @@ -446,7 +446,7 @@ namespace Microsoft.Xna.Framework.Input } else { - System.Console.WriteLine("SCANCODE MISSING FROM XNA->SDL2 DICTIONARY: " + scancode.ToString()); + SDL2_FNAPlatform.Log("SCANCODE MISSING FROM XNA->SDL2 DICTIONARY: " + scancode.ToString()); return Keys.None; } }