Overview
SolarSharp provides comprehensive debugging capabilities including detailed error messages, stack traces, and integration with the Luadebug library.
Error Handling
Basic Exception Handling
Catch and handle script errors:Exception Types
SolarSharp throws specific exception types:Error Locations
Get detailed error location information:Lua pcall and xpcall
Handle errors within Lua:Debug Library
Enable the debug module for advanced debugging:Stack Inspection
Variable Inspection
Upvalue Inspection
Traceback
Generate stack traces:Custom Error Messages
Throw detailed errors from C#:Logging and Monitoring
Capture Print Output
Custom Input Handler
Debugging Best Practices
1. Enable Lua Error Locations
For compatibility with Lua tools:2. Name Your Scripts
Provide friendly names for better error messages:3. Assert Preconditions
4. Use Source Refs
Get detailed location information from C#:Interactive Debugger
Create a simple REPL debugger:Profiling with PerformanceStats
Combine debugging with performance profiling:VS Code Integration
For advanced debugging, consider:- Use the Lua extension
- Configure
.luarc.jsonfor type checking - Use
---@annotations for better IDE support
See Also
Error Handling
Handle script errors gracefully
Performance
Profile and optimize scripts