Always propagate errors with their original context instead of swallowing them or throwing new errors that hide the original cause. This helps with debugging and allows proper error handling up the call stack.
Always propagate errors with their original context instead of swallowing them or throwing new errors that hide the original cause. This helps with debugging and allows proper error handling up the call stack.
Key practices:
Example of proper error propagation:
// Bad - Swallows error with USE
USE(promise->Then(context, callback));
// Good - Propagates error
if (promise->Then(context, callback).IsEmpty()) {
return; // Error already scheduled
}
// Bad - Hides original error
if (!CreateObject(isolate, context).ToLocal(&obj)) {
return ThrowError("Failed to create object");
}
// Good - Preserves original error
if (!CreateObject(isolate, context).ToLocal(&obj)) {
return; // Original error propagates
}
This practice ensures:
Enter the URL of a public GitHub repository