.cursor/skills/native-code-error-handling/SKILL.md
--- name: native-code-error-handling description: Guides native code error handling patterns: exception conversion, error propagation to Dart, user-friendly messages. Use when implementing native code error handling, platform channel error handling, or FFI error handling. --- # Native Code Error Handling ## Core Principle Native code errors must be converted to Dart-friendly errors with user-friendly messages. ## Platform Channel Error Handling ### Swift/iOS ```swift public func handle(_ ca
npx skillsauth add avra-cadavra/avrai .cursor/skills/native-code-error-handlingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Native code errors must be converted to Dart-friendly errors with user-friendly messages.
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
do {
let resultData = try performOperation()
result(resultData)
} catch let error as SpecificError {
result(FlutterError(
code: "SPECIFIC_ERROR",
message: "User-friendly message: \(error.localizedDescription)",
details: nil
))
} catch let error {
result(FlutterError(
code: "OPERATION_ERROR",
message: "Operation failed: \(error.localizedDescription)",
details: nil
))
}
}
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL)
.setMethodCallHandler { call, result ->
try {
when (call.method) {
"performOperation" -> {
val resultData = performOperation()
result.success(resultData)
}
else -> result.notImplemented()
}
} catch (e: SpecificException) {
result.error(
"SPECIFIC_ERROR",
"User-friendly message: ${e.message}",
null
)
} catch (e: Exception) {
result.error(
"OPERATION_ERROR",
"Operation failed: ${e.message}",
e.stackTraceToString()
)
}
}
#[no_mangle]
pub extern "C" fn rust_operation() -> c_int {
match perform_operation() {
Ok(_) => 0, // Success
Err(e) => {
// Log error
eprintln!("Error: {}", e);
-1 // Error code
}
}
}
int performOperation() {
final result = rustOperation();
if (result != 0) {
throw PlatformException(
code: 'OPERATION_ERROR',
message: 'Operation failed with error code: $result',
);
}
return result;
}
Use consistent error codes:
OPERATION_ERROR - Generic operation failurePERMISSION_DENIED - Permission deniedNOT_AVAILABLE - Feature not availableINVALID_ARGUMENT - Invalid inputNETWORK_ERROR - Network failureTIMEOUT - Operation timeoutConvert technical errors to user-friendly messages:
private func getUserFriendlyMessage(from error: Error) -> String {
switch error {
case is PermissionDeniedError:
return "Please grant required permissions in Settings"
case is NetworkError:
return "Connection failed. Please check your internet."
case is TimeoutError:
return "Operation timed out. Please try again."
default:
return "Something went wrong. Please try again."
}
}
development
--- name: world-model-development description: Guides world model development patterns: state/action encoders, ONNX inference, feature extraction pipeline, latency budgets. Use when implementing world model components, state encoders, action encoders, feature extractors, or ONNX models. Core skill for Phases 3-6. --- # World Model Development Patterns ## Core Principle All world model components follow LeCun's autonomous machine intelligence framework. State observations flow through a percep
tools
Implements base workflow controller patterns for multi-step processes. Use when creating complex workflows that require orchestration of multiple steps with error handling and rollback.
testing
--- name: widget-test-patterns description: Guides widget test patterns: BLoC testing, user interactions, state changes, material app setup. Use when writing widget tests, testing UI components, or validating widget behavior. --- # Widget Test Patterns ## Core Pattern Widget tests verify UI behavior: user interactions, state changes, and visual display. ## Basic Widget Test Setup ```dart testWidgets('widget displays correctly', (WidgetTester tester) async { // Arrange: Create widget awa
testing
--- name: test-template-generation description: Generates test templates: unit, widget, integration, service tests following project patterns. Use when creating new tests or ensuring tests follow project standards. --- # Test Template Generation ## Available Templates Test templates are located in `test/templates/`: - `unit_test_template.dart` - `widget_test_template.dart` - `integration_test_template.dart` - `service_test_template.dart` ## Unit Test Template ```dart /// SPOTS Component Uni