rolldown_error 0.1.1

rolldown_error
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::BuildDiagnostic;

pub fn downcast_napi_error_diagnostics(err: anyhow::Error) -> anyhow::Result<BuildDiagnostic> {
  // First try to downcast to BuildDiagnostic itself
  if err.is::<BuildDiagnostic>() {
    return err.downcast::<BuildDiagnostic>();
  }

  #[cfg(feature = "napi")]
  {
    err.downcast::<napi::Error>().map(BuildDiagnostic::napi_error)
  }
  #[cfg(not(feature = "napi"))]
  {
    Err(err)
  }
}