{"record":{"id":"5e011fc841be87b2","repo":"parcel-bundler/parcel","slug":"genericfailure-5e011f","errorCode":"GenericFailure","errorMessage":"An unexpected error occurred","messagePattern":"An unexpected error occurred","errorType":"exception","errorClass":"napi::Error","httpStatus":null,"severity":"error","filePath":"crates/node-bindings/src/html.rs","lineNumber":15,"sourceCode":"use napi::{Env, JsObject, JsUnknown};\nuse napi_derive::napi;\n\n#[napi]\npub fn transform_html(opts: JsObject, env: Env) -> napi::Result<JsUnknown> {\n  let options: parcel_html::TransformOptions = env.from_js_value(opts)?;\n  let result = parcel_html::transform_html(options);\n  env.to_js_value(&result)\n}\n\n#[napi]\npub fn package_html(opts: JsObject, env: Env) -> napi::Result<JsUnknown> {\n  let options: parcel_html::PackageOptions = env.from_js_value(opts)?;\n  let result = parcel_html::package_html(options)\n    .map_err(|_| napi::Error::new(napi::Status::GenericFailure, \"An unexpected error occurred\"))?;\n  env.to_js_value(&result)\n}\n\n#[napi]\npub fn optimize_html(opts: JsObject, env: Env) -> napi::Result<JsUnknown> {\n  let options: parcel_html::OptimizeHtmlOptions = env.from_js_value(opts)?;\n  let result = parcel_html::optimize_html(options)\n    .map_err(|_| napi::Error::new(napi::Status::GenericFailure, \"An unexpected error occurred\"))?;\n  env.to_js_value(&result)\n}\n\n#[napi]\npub fn transform_svg(opts: JsObject, env: Env) -> napi::Result<JsUnknown> {\n  let options: parcel_html::TransformOptions = env.from_js_value(opts)?;\n  let result = parcel_html::transform_svg(options);\n  env.to_js_value(&result)\n}\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/crates/node-bindings/src/html.rs#L1-L33","documentation":"Returned by the package_html napi binding (crates/node-bindings/src/html.rs) when the underlying parcel_html::package_html returns an Err. The .map_err discards the original error and substitutes a generic 'An unexpected error occurred' with Status::GenericFailure, so the JS caller loses the cause. package_html bundles transformed HTML assets into a final HTML output.","triggerScenarios":"parcel_html::package_html(options) returns Err — any internal failure during HTML packaging (asset assembly, source map generation, template interpolation) is masked.","commonSituations":"Invalid package options passed from JS, a corrupted intermediate asset graph, or a bug in the Rust HTML packager. Because the cause is swallowed, debugging requires rebuilding the native binding with the real error exposed.","solutions":["Check the JS-side options object passed to package_html matches PackageOptions exactly (correct types, required fields).","Inspect stderr/Rust logs; if unavailable, build the native crate in debug to surface the original error.","Reproduce with a minimal HTML asset set to isolate which input triggers the packager.","File an issue upstream once the underlying error is identified."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function validatePackageOptions(opts) {\n  if (!opts || typeof opts !== 'object') throw new TypeError('package_html options must be an object');\n  // require the fields the Rust PackageOptions struct expects; adjust to current schema\n  for (const key of ['assets']) if (!(key in opts)) throw new Error('Missing required option: ' + key);\n}","typeGuard":"function isPackageOptions(v) {\n  return v && typeof v === 'object' && Array.isArray(v.assets);\n}","tryCatchPattern":"try {\n  await package_html(opts);\n} catch (e) {\n  if (e?.code === 'GenericFailure' && /unexpected error/i.test(e.message)) {\n    console.error('package_html failed; underlying cause was masked. Rebuild native crate with full error.');\n  }\n  throw e;\n}","preventionTips":["Pass only option shapes documented for PackageOptions.","Keep JS binding version and Rust crate version in sync.","Build the native crate locally to recover masked errors during debugging."],"tags":["html","rust","napi","packaging","error-masking"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}