Repository navigation
v0.1.4: Fix type validation and improve error messages
What's Changed
Bug Fixes
- Prevent panics from
reflect.Call: Added comprehensive type validation to check both argument count and type compatibility before calling functions via reflection - Improved error messages: Error messages now include full context with page names, function paths, and specific type mismatch details
Error Message Improvements
Before:
error executing render operation: argument 1: type string not assignable to parameter type int
After:
error rendering component on page argsComponentTestPage: function github.com/jackielii/structpages.standaloneComponentFunc: argument 1 has type string, expected int
Technical Details
- Added
formatCallable()helper function to extract human-readable function names usingruntime.FuncForPC - Type validation now checks
IsValid()andAssignableTo()for all arguments before calling - Enhanced error context to include page name when available
- Added
TestRenderComponent_TypeMismatchtest to verify type validation
Files Changed
reflect.go: AddedformatCallable()helperstruct_pages_render_component.go: Enhanced validation and error messages inexecuteRenderOpandhandleRenderComponentErrorstruct_pages_test.go: Added type mismatch test and updated existing testsrender_page_component_test.go: Updated test assertions for new error messages
Full Changelog: v0.1.3...v0.1.4