• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / edge-runtime / 13536652177

26 Feb 2025 04:39AM UTC coverage: 47.89% (-0.7%) from 48.599%
13536652177

Pull #503

github

web-flow
Merge 402685cc2 into 1e680abaa
Pull Request #503: fix: add integration tests for commonjs and enhance entrypoint discovery

49 of 54 new or added lines in 3 files covered. (90.74%)

644 existing lines in 8 files now uncovered.

16579 of 34619 relevant lines covered (47.89%)

1629.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.47
/deno/runtime/errors.rs
1
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2

3
//! There are many types of errors in Deno:
4
//! - AnyError: a generic wrapper that can encapsulate any type of error.
5
//! - JsError: a container for the error message and stack trace for exceptions
6
//!   thrown in JavaScript code. We use this to pretty-print stack traces.
7
//! - Diagnostic: these are errors that originate in TypeScript's compiler.
8
//!   They're similar to JsError, in that they have line numbers. But
9
//!   Diagnostics are compile-time type errors, whereas JsErrors are runtime
10
//!   exceptions.
11

12
use crate::runtime::ops::permissions::PermissionError;
13
// use crate::ops::fs_events::FsEventsError;
14
// use crate::ops::http::HttpStartError;
15
// use crate::ops::os::OsError;
16
// use crate::ops::permissions::PermissionError;
17
// use crate::ops::process::CheckRunPermissionError;
18
// use crate::ops::process::ProcessError;
19
// use crate::ops::signal::SignalError;
20
// use crate::ops::tty::TtyError;
21
// use crate::ops::web_worker::SyncFetchError;
22
// use crate::ops::worker_host::CreateWorkerError;
23
// use deno_broadcast_channel::BroadcastChannelError;
24
// use deno_cache::CacheError;
25
// use deno_canvas::CanvasError;
26
use deno_core::error::AnyError;
27
use deno_core::serde_json;
28
use deno_core::url;
29
use deno_core::ModuleResolutionError;
30
// use deno_cron::CronError;
31
use deno_crypto::DecryptError;
32
use deno_crypto::EncryptError;
33
use deno_crypto::ExportKeyError;
34
use deno_crypto::GenerateKeyError;
35
use deno_crypto::ImportKeyError;
36
use deno_fetch::FetchError;
37
use deno_fetch::HttpClientCreateError;
38
// use deno_ffi::CallError;
39
// use deno_ffi::CallbackError;
40
// use deno_ffi::DlfcnError;
41
// use deno_ffi::IRError;
42
// use deno_ffi::ReprError;
43
// use deno_ffi::StaticError;
44
use deno_fs::FsOpsError;
45
use deno_fs::FsOpsErrorKind;
46
use deno_http::HttpError;
47
use deno_http::HttpNextError;
48
use deno_http::WebSocketUpgradeError;
49
use deno_io::fs::FsError;
50
// use deno_kv::KvCheckError;
51
// use deno_kv::KvError;
52
// use deno_kv::KvErrorKind;
53
// use deno_kv::KvMutationError;
54
// use deno_napi::NApiError;
55
use deno_net::ops::NetError;
56
use deno_permissions::ChildPermissionError;
57
use deno_permissions::NetDescriptorFromUrlParseError;
58
use deno_permissions::PathResolveError;
59
use deno_permissions::PermissionCheckError;
60
use deno_permissions::RunDescriptorParseError;
61
use deno_permissions::SysDescriptorParseError;
62
use deno_tls::TlsError;
63
use deno_web::BlobError;
64
use deno_web::CompressionError;
65
use deno_web::MessagePortError;
66
use deno_web::StreamResourceError;
67
use deno_web::WebError;
68
use deno_websocket::HandshakeError;
69
use deno_websocket::WebsocketError;
70
use deno_webstorage::WebStorageError;
71
// use rustyline::error::ReadlineError;
72
use std::env;
73
use std::error::Error;
74
use std::io;
75
use std::sync::Arc;
76

77
fn get_run_descriptor_parse_error(e: &RunDescriptorParseError) -> &'static str {
×
78
  match e {
×
79
    RunDescriptorParseError::Which(_) => "Error",
×
80
    RunDescriptorParseError::PathResolve(e) => get_path_resolve_error(e),
×
81
    RunDescriptorParseError::EmptyRunQuery => "Error",
×
82
  }
83
}
×
84

85
fn get_sys_descriptor_parse_error(e: &SysDescriptorParseError) -> &'static str {
×
86
  match e {
×
87
    SysDescriptorParseError::InvalidKind(_) => "TypeError",
×
88
    SysDescriptorParseError::Empty => "Error",
×
89
  }
90
}
×
91

92
fn get_path_resolve_error(e: &PathResolveError) -> &'static str {
×
93
  match e {
×
94
    PathResolveError::CwdResolve(e) => get_io_error_class(e),
×
95
    PathResolveError::EmptyPath => "Error",
×
96
  }
97
}
×
98

99
fn get_permission_error_class(e: &PermissionError) -> &'static str {
×
100
  match e {
×
101
    PermissionError::InvalidPermissionName(_) => "ReferenceError",
×
102
    PermissionError::PathResolve(e) => get_path_resolve_error(e),
×
103
    PermissionError::NetDescriptorParse(_) => "URIError",
×
104
    PermissionError::SysDescriptorParse(e) => get_sys_descriptor_parse_error(e),
×
105
    PermissionError::RunDescriptorParse(e) => get_run_descriptor_parse_error(e),
×
106
  }
107
}
×
108

109
fn get_permission_check_error_class(e: &PermissionCheckError) -> &'static str {
2✔
110
  match e {
2✔
111
    PermissionCheckError::PermissionDenied(_) => "NotCapable",
2✔
112
    PermissionCheckError::InvalidFilePath(_) => "URIError",
×
113
    PermissionCheckError::NetDescriptorForUrlParse(e) => match e {
×
114
      NetDescriptorFromUrlParseError::MissingHost(_) => "TypeError",
×
115
      NetDescriptorFromUrlParseError::Host(_) => "URIError",
×
116
    },
117
    PermissionCheckError::SysDescriptorParse(e) => {
×
118
      get_sys_descriptor_parse_error(e)
×
119
    }
120
    PermissionCheckError::PathResolve(e) => get_path_resolve_error(e),
×
121
    PermissionCheckError::HostParse(_) => "URIError",
×
122
  }
123
}
2✔
124

125
// fn get_dlopen_error_class(error: &dlopen2::Error) -> &'static str {
126
//   use dlopen2::Error::*;
127
//   match error {
128
//     NullCharacter(_) => "InvalidData",
129
//     OpeningLibraryError(ref e) => get_io_error_class(e),
130
//     SymbolGettingError(ref e) => get_io_error_class(e),
131
//     AddrNotMatchingDll(ref e) => get_io_error_class(e),
132
//     NullSymbol => "NotFound",
133
//   }
134
// }
135

136
fn get_env_var_error_class(error: &env::VarError) -> &'static str {
×
137
  use env::VarError::*;
138
  match error {
×
139
    NotPresent => "NotFound",
×
140
    NotUnicode(..) => "InvalidData",
×
141
  }
142
}
×
143

144
fn get_io_error_class(error: &io::Error) -> &'static str {
15✔
145
  use io::ErrorKind::*;
146
  match error.kind() {
15✔
147
    NotFound => "NotFound",
1✔
148
    PermissionDenied => "PermissionDenied",
×
149
    ConnectionRefused => "ConnectionRefused",
×
150
    ConnectionReset => "ConnectionReset",
×
151
    ConnectionAborted => "ConnectionAborted",
×
152
    NotConnected => "NotConnected",
×
153
    AddrInUse => "AddrInUse",
×
154
    AddrNotAvailable => "AddrNotAvailable",
×
155
    BrokenPipe => "BrokenPipe",
×
156
    AlreadyExists => "AlreadyExists",
×
157
    InvalidInput => "TypeError",
×
158
    InvalidData => "InvalidData",
1✔
159
    TimedOut => "TimedOut",
×
160
    Interrupted => "Interrupted",
13✔
161
    WriteZero => "WriteZero",
×
162
    UnexpectedEof => "UnexpectedEof",
×
UNCOV
163
    Other => "Error",
×
164
    WouldBlock => "WouldBlock",
×
165
    // Non-exhaustive enum - might add new variants
166
    // in the future
167
    kind => {
×
168
      let kind_str = kind.to_string();
×
169
      match kind_str.as_str() {
×
170
        "FilesystemLoop" => "FilesystemLoop",
×
171
        "IsADirectory" => "IsADirectory",
×
172
        "NetworkUnreachable" => "NetworkUnreachable",
×
173
        "NotADirectory" => "NotADirectory",
×
174
        _ => "Error",
×
175
      }
176
    }
177
  }
178
}
15✔
179

180
fn get_module_resolution_error_class(
×
181
  _: &ModuleResolutionError,
×
182
) -> &'static str {
×
183
  "URIError"
×
184
}
×
185

186
fn get_notify_error_class(error: &notify::Error) -> &'static str {
×
187
  use notify::ErrorKind::*;
188
  match error.kind {
×
189
    Generic(_) => "Error",
×
190
    Io(ref e) => get_io_error_class(e),
×
191
    PathNotFound => "NotFound",
×
192
    WatchNotFound => "NotFound",
×
193
    InvalidConfig(_) => "InvalidData",
×
194
    MaxFilesWatch => "Error",
×
195
  }
196
}
×
197

198
fn get_regex_error_class(error: &regex::Error) -> &'static str {
×
199
  use regex::Error::*;
200
  match error {
×
201
    Syntax(_) => "SyntaxError",
×
202
    CompiledTooBig(_) => "RangeError",
×
203
    _ => "Error",
×
204
  }
205
}
×
206

207
fn get_serde_json_error_class(
×
208
  error: &serde_json::error::Error,
×
209
) -> &'static str {
×
210
  use deno_core::serde_json::error::*;
211
  match error.classify() {
×
212
    Category::Io => error
×
213
      .source()
×
214
      .and_then(|e| e.downcast_ref::<io::Error>())
×
215
      .map(get_io_error_class)
×
216
      .unwrap(),
×
217
    Category::Syntax => "SyntaxError",
×
218
    Category::Data => "InvalidData",
×
219
    Category::Eof => "UnexpectedEof",
×
220
  }
221
}
×
222

223
fn get_url_parse_error_class(_error: &url::ParseError) -> &'static str {
×
224
  "URIError"
×
225
}
×
226

227
fn get_hyper_error_class(_error: &hyper::Error) -> &'static str {
×
228
  "Http"
×
229
}
×
230

231
fn get_hyper_util_error_class(
×
232
  _error: &hyper_util::client::legacy::Error,
×
233
) -> &'static str {
×
234
  "Http"
×
235
}
×
236

237
fn get_hyper_v014_error_class(_error: &hyper_v014::Error) -> &'static str {
10✔
238
  "Http"
10✔
239
}
10✔
240

241
#[cfg(unix)]
242
pub fn get_nix_error_class(error: &nix::Error) -> &'static str {
×
243
  match error {
×
244
    nix::Error::ECHILD => "NotFound",
×
245
    nix::Error::EINVAL => "TypeError",
×
246
    nix::Error::ENOENT => "NotFound",
×
247
    nix::Error::ENOTTY => "BadResource",
×
248
    nix::Error::EPERM => "PermissionDenied",
×
249
    nix::Error::ESRCH => "NotFound",
×
250
    nix::Error::ELOOP => "FilesystemLoop",
×
251
    nix::Error::ENOTDIR => "NotADirectory",
×
252
    nix::Error::ENETUNREACH => "NetworkUnreachable",
×
253
    nix::Error::EISDIR => "IsADirectory",
×
254
    nix::Error::UnknownErrno => "Error",
×
255
    &nix::Error::ENOTSUP => unreachable!(),
×
256
    _ => "Error",
×
257
  }
258
}
×
259

260
// fn get_webgpu_error_class(e: &deno_webgpu::InitError) -> &'static str {
261
//   match e {
262
//     deno_webgpu::InitError::Resource(e) => {
263
//       get_error_class_name(e).unwrap_or("Error")
264
//     }
265
//     deno_webgpu::InitError::InvalidAdapter(_) => "Error",
266
//     deno_webgpu::InitError::RequestDevice(_) => "DOMExceptionOperationError",
267
//     deno_webgpu::InitError::InvalidDevice(_) => "Error",
268
//   }
269
// }
270

271
// fn get_webgpu_buffer_error_class(
272
//   e: &deno_webgpu::buffer::BufferError,
273
// ) -> &'static str {
274
//   match e {
275
//     deno_webgpu::buffer::BufferError::Resource(e) => {
276
//       get_error_class_name(e).unwrap_or("Error")
277
//     }
278
//     deno_webgpu::buffer::BufferError::InvalidUsage => "TypeError",
279
//     deno_webgpu::buffer::BufferError::Access(_) => "DOMExceptionOperationError",
280
//   }
281
// }
282

283
// fn get_webgpu_bundle_error_class(
284
//   e: &deno_webgpu::bundle::BundleError,
285
// ) -> &'static str {
286
//   match e {
287
//     deno_webgpu::bundle::BundleError::Resource(e) => {
288
//       get_error_class_name(e).unwrap_or("Error")
289
//     }
290
//     deno_webgpu::bundle::BundleError::InvalidSize => "TypeError",
291
//   }
292
// }
293

294
// fn get_webgpu_byow_error_class(
295
//   e: &deno_webgpu::byow::ByowError,
296
// ) -> &'static str {
297
//   match e {
298
//     deno_webgpu::byow::ByowError::WebGPUNotInitiated => "TypeError",
299
//     deno_webgpu::byow::ByowError::InvalidParameters => "TypeError",
300
//     deno_webgpu::byow::ByowError::CreateSurface(_) => "Error",
301
//     deno_webgpu::byow::ByowError::InvalidSystem => "TypeError",
302
//     #[cfg(any(
303
//       target_os = "windows",
304
//       target_os = "linux",
305
//       target_os = "freebsd",
306
//       target_os = "openbsd"
307
//     ))]
308
//     deno_webgpu::byow::ByowError::NullWindow => "TypeError",
309
//     #[cfg(any(
310
//       target_os = "linux",
311
//       target_os = "freebsd",
312
//       target_os = "openbsd"
313
//     ))]
314
//     deno_webgpu::byow::ByowError::NullDisplay => "TypeError",
315
//     #[cfg(target_os = "macos")]
316
//     deno_webgpu::byow::ByowError::NSViewDisplay => "TypeError",
317
//   }
318
// }
319

320
// fn get_webgpu_render_pass_error_class(
321
//   e: &deno_webgpu::render_pass::RenderPassError,
322
// ) -> &'static str {
323
//   match e {
324
//     deno_webgpu::render_pass::RenderPassError::Resource(e) => {
325
//       get_error_class_name(e).unwrap_or("Error")
326
//     }
327
//     deno_webgpu::render_pass::RenderPassError::InvalidSize => "TypeError",
328
//   }
329
// }
330

331
// fn get_webgpu_surface_error_class(
332
//   e: &deno_webgpu::surface::SurfaceError,
333
// ) -> &'static str {
334
//   match e {
335
//     deno_webgpu::surface::SurfaceError::Resource(e) => {
336
//       get_error_class_name(e).unwrap_or("Error")
337
//     }
338
//     deno_webgpu::surface::SurfaceError::Surface(_) => "Error",
339
//     deno_webgpu::surface::SurfaceError::InvalidStatus => "Error",
340
//   }
341
// }
342

343
fn get_crypto_decrypt_error_class(e: &DecryptError) -> &'static str {
×
344
  match e {
×
345
    DecryptError::General(e) => get_crypto_shared_error_class(e),
×
346
    DecryptError::Pkcs1(_) => "Error",
×
347
    DecryptError::Failed => "DOMExceptionOperationError",
×
348
    DecryptError::InvalidLength => "TypeError",
×
349
    DecryptError::InvalidCounterLength => "TypeError",
×
350
    DecryptError::InvalidTagLength => "TypeError",
×
351
    DecryptError::InvalidKeyOrIv => "DOMExceptionOperationError",
×
352
    DecryptError::TooMuchData => "DOMExceptionOperationError",
×
353
    DecryptError::InvalidIvLength => "TypeError",
×
354
    DecryptError::Rsa(_) => "DOMExceptionOperationError",
×
355
  }
356
}
×
357

358
fn get_crypto_encrypt_error_class(e: &EncryptError) -> &'static str {
×
359
  match e {
×
360
    EncryptError::General(e) => get_crypto_shared_error_class(e),
×
361
    EncryptError::InvalidKeyOrIv => "DOMExceptionOperationError",
×
362
    EncryptError::Failed => "DOMExceptionOperationError",
×
363
    EncryptError::InvalidLength => "TypeError",
×
364
    EncryptError::InvalidIvLength => "TypeError",
×
365
    EncryptError::InvalidCounterLength => "TypeError",
×
366
    EncryptError::TooMuchData => "DOMExceptionOperationError",
×
367
  }
368
}
×
369

370
fn get_crypto_shared_error_class(e: &deno_crypto::SharedError) -> &'static str {
×
371
  match e {
×
372
    deno_crypto::SharedError::ExpectedValidPrivateKey => "TypeError",
×
373
    deno_crypto::SharedError::ExpectedValidPublicKey => "TypeError",
×
374
    deno_crypto::SharedError::ExpectedValidPrivateECKey => "TypeError",
×
375
    deno_crypto::SharedError::ExpectedValidPublicECKey => "TypeError",
×
376
    deno_crypto::SharedError::ExpectedPrivateKey => "TypeError",
×
377
    deno_crypto::SharedError::ExpectedPublicKey => "TypeError",
×
378
    deno_crypto::SharedError::ExpectedSecretKey => "TypeError",
×
379
    deno_crypto::SharedError::FailedDecodePrivateKey => {
380
      "DOMExceptionOperationError"
×
381
    }
382
    deno_crypto::SharedError::FailedDecodePublicKey => {
383
      "DOMExceptionOperationError"
×
384
    }
385
    deno_crypto::SharedError::UnsupportedFormat => {
386
      "DOMExceptionNotSupportedError"
×
387
    }
388
  }
389
}
×
390

391
fn get_crypto_ed25519_error_class(
×
392
  e: &deno_crypto::Ed25519Error,
×
393
) -> &'static str {
×
394
  match e {
×
395
    deno_crypto::Ed25519Error::FailedExport => "DOMExceptionOperationError",
×
396
    deno_crypto::Ed25519Error::Der(_) => "Error",
×
397
    deno_crypto::Ed25519Error::KeyRejected(_) => "Error",
×
398
  }
399
}
×
400

401
fn get_crypto_export_key_error_class(e: &ExportKeyError) -> &'static str {
×
402
  match e {
×
403
    ExportKeyError::General(e) => get_crypto_shared_error_class(e),
×
404
    ExportKeyError::Der(_) => "Error",
×
405
    ExportKeyError::UnsupportedNamedCurve => "DOMExceptionNotSupportedError",
×
406
  }
407
}
×
408

409
fn get_crypto_generate_key_error_class(e: &GenerateKeyError) -> &'static str {
×
410
  match e {
×
411
    GenerateKeyError::General(e) => get_crypto_shared_error_class(e),
×
412
    GenerateKeyError::BadPublicExponent => "DOMExceptionOperationError",
×
413
    GenerateKeyError::InvalidHMACKeyLength => "DOMExceptionOperationError",
×
414
    GenerateKeyError::FailedRSAKeySerialization => "DOMExceptionOperationError",
×
415
    GenerateKeyError::InvalidAESKeyLength => "DOMExceptionOperationError",
×
416
    GenerateKeyError::FailedRSAKeyGeneration => "DOMExceptionOperationError",
×
417
    GenerateKeyError::FailedECKeyGeneration => "DOMExceptionOperationError",
×
418
    GenerateKeyError::FailedKeyGeneration => "DOMExceptionOperationError",
×
419
  }
420
}
×
421

422
fn get_crypto_import_key_error_class(e: &ImportKeyError) -> &'static str {
×
423
  match e {
×
424
    ImportKeyError::General(e) => get_crypto_shared_error_class(e),
×
425
    ImportKeyError::InvalidModulus => "DOMExceptionDataError",
×
426
    ImportKeyError::InvalidPublicExponent => "DOMExceptionDataError",
×
427
    ImportKeyError::InvalidPrivateExponent => "DOMExceptionDataError",
×
428
    ImportKeyError::InvalidFirstPrimeFactor => "DOMExceptionDataError",
×
429
    ImportKeyError::InvalidSecondPrimeFactor => "DOMExceptionDataError",
×
430
    ImportKeyError::InvalidFirstCRTExponent => "DOMExceptionDataError",
×
431
    ImportKeyError::InvalidSecondCRTExponent => "DOMExceptionDataError",
×
432
    ImportKeyError::InvalidCRTCoefficient => "DOMExceptionDataError",
×
433
    ImportKeyError::InvalidB64Coordinate => "DOMExceptionDataError",
×
434
    ImportKeyError::InvalidRSAPublicKey => "DOMExceptionDataError",
×
435
    ImportKeyError::InvalidRSAPrivateKey => "DOMExceptionDataError",
×
436
    ImportKeyError::UnsupportedAlgorithm => "DOMExceptionDataError",
×
437
    ImportKeyError::PublicKeyTooLong => "DOMExceptionDataError",
×
438
    ImportKeyError::PrivateKeyTooLong => "DOMExceptionDataError",
×
439
    ImportKeyError::InvalidP256ECPoint => "DOMExceptionDataError",
×
440
    ImportKeyError::InvalidP384ECPoint => "DOMExceptionDataError",
×
441
    ImportKeyError::InvalidP521ECPoint => "DOMExceptionDataError",
×
442
    ImportKeyError::UnsupportedNamedCurve => "DOMExceptionDataError",
×
443
    ImportKeyError::CurveMismatch => "DOMExceptionDataError",
×
444
    ImportKeyError::InvalidKeyData => "DOMExceptionDataError",
×
445
    ImportKeyError::InvalidJWKPrivateKey => "DOMExceptionDataError",
×
446
    ImportKeyError::EllipticCurve(_) => "DOMExceptionDataError",
×
447
    ImportKeyError::ExpectedValidPkcs8Data => "DOMExceptionDataError",
×
448
    ImportKeyError::MalformedParameters => "DOMExceptionDataError",
×
449
    ImportKeyError::Spki(_) => "DOMExceptionDataError",
×
450
    ImportKeyError::InvalidP256ECSPKIData => "DOMExceptionDataError",
×
451
    ImportKeyError::InvalidP384ECSPKIData => "DOMExceptionDataError",
×
452
    ImportKeyError::InvalidP521ECSPKIData => "DOMExceptionDataError",
×
453
    ImportKeyError::Der(_) => "DOMExceptionDataError",
×
454
  }
455
}
×
456

457
fn get_crypto_x448_error_class(e: &deno_crypto::X448Error) -> &'static str {
×
458
  match e {
×
459
    deno_crypto::X448Error::FailedExport => "DOMExceptionOperationError",
×
460
    deno_crypto::X448Error::Der(_) => "Error",
×
461
  }
462
}
×
463

464
fn get_crypto_x25519_error_class(e: &deno_crypto::X25519Error) -> &'static str {
×
465
  match e {
×
466
    deno_crypto::X25519Error::FailedExport => "DOMExceptionOperationError",
×
467
    deno_crypto::X25519Error::Der(_) => "Error",
×
468
  }
469
}
×
470

471
fn get_crypto_error_class(e: &deno_crypto::Error) -> &'static str {
×
472
  match e {
×
473
    deno_crypto::Error::Der(_) => "Error",
×
474
    deno_crypto::Error::JoinError(_) => "Error",
×
475
    deno_crypto::Error::MissingArgumentHash => "TypeError",
×
476
    deno_crypto::Error::MissingArgumentSaltLength => "TypeError",
×
477
    deno_crypto::Error::Other(e) => get_error_class_name(e).unwrap_or("Error"),
×
478
    deno_crypto::Error::UnsupportedAlgorithm => "TypeError",
×
479
    deno_crypto::Error::KeyRejected(_) => "Error",
×
480
    deno_crypto::Error::RSA(_) => "Error",
×
481
    deno_crypto::Error::Pkcs1(_) => "Error",
×
482
    deno_crypto::Error::Unspecified(_) => "Error",
×
483
    deno_crypto::Error::InvalidKeyFormat => "TypeError",
×
484
    deno_crypto::Error::MissingArgumentPublicKey => "TypeError",
×
485
    deno_crypto::Error::P256Ecdsa(_) => "Error",
×
486
    deno_crypto::Error::DecodePrivateKey => "TypeError",
×
487
    deno_crypto::Error::MissingArgumentNamedCurve => "TypeError",
×
488
    deno_crypto::Error::MissingArgumentInfo => "TypeError",
×
489
    deno_crypto::Error::HKDFLengthTooLarge => "DOMExceptionOperationError",
×
490
    deno_crypto::Error::General(e) => get_crypto_shared_error_class(e),
×
491
    deno_crypto::Error::Base64Decode(_) => "Error",
×
492
    deno_crypto::Error::DataInvalidSize => "TypeError",
×
493
    deno_crypto::Error::InvalidKeyLength => "TypeError",
×
494
    deno_crypto::Error::EncryptionError => "DOMExceptionOperationError",
×
495
    deno_crypto::Error::DecryptionError => "DOMExceptionOperationError",
×
496
    deno_crypto::Error::ArrayBufferViewLengthExceeded(_) => {
497
      "DOMExceptionQuotaExceededError"
×
498
    }
499
  }
500
}
×
501

502
// fn get_napi_error_class(e: &NApiError) -> &'static str {
503
//   match e {
504
//     NApiError::InvalidPath
505
//     | NApiError::LibLoading(_)
506
//     | NApiError::ModuleNotFound(_) => "TypeError",
507
//     NApiError::Permission(e) => get_permission_check_error_class(e),
508
//   }
509
// }
510

511
fn get_web_error_class(e: &WebError) -> &'static str {
×
512
  match e {
×
513
    WebError::Base64Decode => "DOMExceptionInvalidCharacterError",
×
514
    WebError::InvalidEncodingLabel(_) => "RangeError",
×
515
    WebError::BufferTooLong => "TypeError",
×
516
    WebError::ValueTooLarge => "RangeError",
×
517
    WebError::BufferTooSmall => "RangeError",
×
518
    WebError::DataInvalid => "TypeError",
×
519
    WebError::DataError(_) => "Error",
×
520
  }
521
}
×
522

523
fn get_web_compression_error_class(e: &CompressionError) -> &'static str {
×
524
  match e {
×
525
    CompressionError::UnsupportedFormat => "TypeError",
×
526
    CompressionError::ResourceClosed => "TypeError",
×
527
    CompressionError::IoTypeError(_) => "TypeError",
×
528
    CompressionError::Io(e) => get_io_error_class(e),
×
529
  }
530
}
×
531

532
fn get_web_message_port_error_class(e: &MessagePortError) -> &'static str {
×
533
  match e {
×
534
    MessagePortError::InvalidTransfer => "TypeError",
×
535
    MessagePortError::NotReady => "TypeError",
×
536
    MessagePortError::TransferSelf => "TypeError",
×
537
    MessagePortError::Canceled(e) => {
×
538
      let io_err: io::Error = e.to_owned().into();
×
539
      get_io_error_class(&io_err)
×
540
    }
541
    MessagePortError::Resource(e) => get_error_class_name(e).unwrap_or("Error"),
×
542
  }
543
}
×
544

545
fn get_web_stream_resource_error_class(
×
546
  e: &StreamResourceError,
×
547
) -> &'static str {
×
548
  match e {
×
549
    StreamResourceError::Canceled(e) => {
×
550
      let io_err: io::Error = e.to_owned().into();
×
551
      get_io_error_class(&io_err)
×
552
    }
553
    StreamResourceError::Js(_) => "TypeError",
×
554
  }
555
}
×
556

557
fn get_web_blob_error_class(e: &BlobError) -> &'static str {
×
558
  match e {
×
559
    BlobError::BlobPartNotFound => "TypeError",
×
560
    BlobError::SizeLargerThanBlobPart => "TypeError",
×
561
    BlobError::BlobURLsNotSupported => "TypeError",
×
562
    BlobError::Url(_) => "Error",
×
563
  }
564
}
×
565

566
// fn get_ffi_repr_error_class(e: &ReprError) -> &'static str {
567
//   match e {
568
//     ReprError::InvalidOffset => "TypeError",
569
//     ReprError::InvalidArrayBuffer => "TypeError",
570
//     ReprError::DestinationLengthTooShort => "RangeError",
571
//     ReprError::InvalidCString => "TypeError",
572
//     ReprError::CStringTooLong => "TypeError",
573
//     ReprError::InvalidBool => "TypeError",
574
//     ReprError::InvalidU8 => "TypeError",
575
//     ReprError::InvalidI8 => "TypeError",
576
//     ReprError::InvalidU16 => "TypeError",
577
//     ReprError::InvalidI16 => "TypeError",
578
//     ReprError::InvalidU32 => "TypeError",
579
//     ReprError::InvalidI32 => "TypeError",
580
//     ReprError::InvalidU64 => "TypeError",
581
//     ReprError::InvalidI64 => "TypeError",
582
//     ReprError::InvalidF32 => "TypeError",
583
//     ReprError::InvalidF64 => "TypeError",
584
//     ReprError::InvalidPointer => "TypeError",
585
//     ReprError::Permission(e) => get_permission_check_error_class(e),
586
//   }
587
// }
588

589
// fn get_ffi_dlfcn_error_class(e: &DlfcnError) -> &'static str {
590
//   match e {
591
//     DlfcnError::RegisterSymbol { .. } => "Error",
592
//     DlfcnError::Dlopen(_) => "Error",
593
//     DlfcnError::Permission(e) => get_permission_check_error_class(e),
594
//     DlfcnError::Other(e) => get_error_class_name(e).unwrap_or("Error"),
595
//   }
596
// }
597

598
// fn get_ffi_static_error_class(e: &StaticError) -> &'static str {
599
//   match e {
600
//     StaticError::Dlfcn(e) => get_ffi_dlfcn_error_class(e),
601
//     StaticError::InvalidTypeVoid => "TypeError",
602
//     StaticError::InvalidTypeStruct => "TypeError",
603
//     StaticError::Resource(e) => get_error_class_name(e).unwrap_or("Error"),
604
//   }
605
// }
606

607
// fn get_ffi_callback_error_class(e: &CallbackError) -> &'static str {
608
//   match e {
609
//     CallbackError::Resource(e) => get_error_class_name(e).unwrap_or("Error"),
610
//     CallbackError::Other(e) => get_error_class_name(e).unwrap_or("Error"),
611
//     CallbackError::Permission(e) => get_permission_check_error_class(e),
612
//   }
613
// }
614

615
// fn get_ffi_call_error_class(e: &CallError) -> &'static str {
616
//   match e {
617
//     CallError::IR(_) => "TypeError",
618
//     CallError::NonblockingCallFailure(_) => "Error",
619
//     CallError::InvalidSymbol(_) => "TypeError",
620
//     CallError::Permission(e) => get_permission_check_error_class(e),
621
//     CallError::Callback(e) => get_ffi_callback_error_class(e),
622
//     CallError::Resource(e) => get_error_class_name(e).unwrap_or("Error"),
623
//   }
624
// }
625

626
fn get_webstorage_class_name(e: &WebStorageError) -> &'static str {
×
627
  match e {
×
628
    WebStorageError::ContextNotSupported => "DOMExceptionNotSupportedError",
×
629
    WebStorageError::Sqlite(_) => "Error",
×
630
    WebStorageError::Io(e) => get_io_error_class(e),
×
631
    WebStorageError::StorageExceeded => "DOMExceptionQuotaExceededError",
×
632
  }
633
}
×
634

635
fn get_tls_error_class(e: &TlsError) -> &'static str {
×
636
  match e {
×
637
    TlsError::Rustls(_) => "Error",
×
638
    TlsError::UnableAddPemFileToCert(e) => get_io_error_class(e),
×
639
    TlsError::CertInvalid
640
    | TlsError::CertsNotFound
641
    | TlsError::KeysNotFound
642
    | TlsError::KeyDecode => "InvalidData",
×
643
  }
644
}
×
645

646
// pub fn get_cron_error_class(e: &CronError) -> &'static str {
647
//   match e {
648
//     CronError::Resource(e) => {
649
//       deno_core::error::get_custom_error_class(e).unwrap_or("Error")
650
//     }
651
//     CronError::NameExceeded(_) => "TypeError",
652
//     CronError::NameInvalid => "TypeError",
653
//     CronError::AlreadyExists => "TypeError",
654
//     CronError::TooManyCrons => "TypeError",
655
//     CronError::InvalidCron => "TypeError",
656
//     CronError::InvalidBackoff => "TypeError",
657
//     CronError::AcquireError(_) => "Error",
658
//     CronError::Other(e) => get_error_class_name(e).unwrap_or("Error"),
659
//   }
660
// }
661

662
// fn get_canvas_error(e: &CanvasError) -> &'static str {
663
//   match e {
664
//     CanvasError::UnsupportedColorType(_) => "TypeError",
665
//     CanvasError::Image(_) => "Error",
666
//   }
667
// }
668

669
// pub fn get_cache_error(error: &CacheError) -> &'static str {
670
//   match error {
671
//     CacheError::Sqlite(_) => "Error",
672
//     CacheError::JoinError(_) => "Error",
673
//     CacheError::Resource(err) => {
674
//       deno_core::error::get_custom_error_class(err).unwrap_or("Error")
675
//     }
676
//     CacheError::Other(e) => get_error_class_name(e).unwrap_or("Error"),
677
//     CacheError::Io(err) => get_io_error_class(err),
678
//   }
679
// }
680

681
// fn get_broadcast_channel_error(error: &BroadcastChannelError) -> &'static str {
682
//   match error {
683
//     BroadcastChannelError::Resource(err) => {
684
//       deno_core::error::get_custom_error_class(err).unwrap()
685
//     }
686
//     BroadcastChannelError::MPSCSendError(_) => "Error",
687
//     BroadcastChannelError::BroadcastSendError(_) => "Error",
688
//     BroadcastChannelError::Other(err) => {
689
//       get_error_class_name(err).unwrap_or("Error")
690
//     }
691
//   }
692
// }
693

694
fn get_fetch_error(error: &FetchError) -> &'static str {
2✔
695
  match error {
2✔
696
    FetchError::Resource(e) => get_error_class_name(e).unwrap_or("Error"),
×
697
    FetchError::Permission(e) => get_permission_check_error_class(e),
2✔
698
    FetchError::NetworkError => "TypeError",
×
699
    FetchError::FsNotGet(_) => "TypeError",
×
700
    FetchError::PathToUrl(_) => "TypeError",
×
701
    FetchError::InvalidUrl(_) => "TypeError",
×
702
    FetchError::InvalidHeaderName(_) => "TypeError",
×
703
    FetchError::InvalidHeaderValue(_) => "TypeError",
×
704
    FetchError::DataUrl(_) => "TypeError",
×
705
    FetchError::Base64(_) => "TypeError",
×
706
    FetchError::BlobNotFound => "TypeError",
×
707
    FetchError::SchemeNotSupported(_) => "TypeError",
×
708
    FetchError::RequestCanceled => "TypeError",
×
709
    FetchError::Http(_) => "Error",
×
710
    FetchError::ClientCreate(e) => get_http_client_create_error(e),
×
711
    FetchError::Url(e) => get_url_parse_error_class(e),
×
712
    FetchError::Method(_) => "TypeError",
×
713
    FetchError::ClientSend(_) => "TypeError",
×
714
    FetchError::RequestBuilderHook(_) => "TypeError",
×
715
    FetchError::Io(e) => get_io_error_class(e),
×
716
    FetchError::Hyper(e) => get_hyper_error_class(e),
×
717
  }
718
}
2✔
719

720
fn get_http_client_create_error(error: &HttpClientCreateError) -> &'static str {
×
721
  match error {
×
722
    HttpClientCreateError::Tls(_) => "TypeError",
×
723
    HttpClientCreateError::InvalidUserAgent(_) => "TypeError",
×
724
    HttpClientCreateError::InvalidProxyUrl => "TypeError",
×
725
    HttpClientCreateError::HttpVersionSelectionInvalid => "TypeError",
×
726
    HttpClientCreateError::RootCertStore(_) => "TypeError",
×
727
  }
728
}
×
729

730
fn get_websocket_error(error: &WebsocketError) -> &'static str {
×
731
  match error {
×
732
    WebsocketError::Resource(e) => get_error_class_name(e).unwrap_or("Error"),
×
733
    WebsocketError::Permission(e) => get_permission_check_error_class(e),
×
734
    WebsocketError::Url(e) => get_url_parse_error_class(e),
×
735
    WebsocketError::Io(e) => get_io_error_class(e),
×
736
    WebsocketError::WebSocket(_) => "TypeError",
×
737
    WebsocketError::ConnectionFailed(_) => "DOMExceptionNetworkError",
×
738
    WebsocketError::Uri(_) => "Error",
×
739
    WebsocketError::Canceled(e) => {
×
740
      let io_err: io::Error = e.to_owned().into();
×
741
      get_io_error_class(&io_err)
×
742
    }
743
  }
744
}
×
745

746
fn get_websocket_handshake_error(error: &HandshakeError) -> &'static str {
×
747
  match error {
×
748
    HandshakeError::RootStoreError(e) => {
×
749
      get_error_class_name(e).unwrap_or("Error")
×
750
    }
751
    HandshakeError::Tls(e) => get_tls_error_class(e),
×
752
    HandshakeError::MissingPath => "TypeError",
×
753
    HandshakeError::Http(_) => "Error",
×
754
    HandshakeError::InvalidHostname(_) => "TypeError",
×
755
    HandshakeError::Io(e) => get_io_error_class(e),
×
756
    HandshakeError::Rustls(_) => "Error",
×
757
    HandshakeError::H2(_) => "Error",
×
758
    HandshakeError::NoH2Alpn => "Error",
×
759
    HandshakeError::InvalidStatusCode(_) => "Error",
×
760
    HandshakeError::WebSocket(_) => "TypeError",
×
761
    HandshakeError::HeaderName(_) => "TypeError",
×
762
    HandshakeError::HeaderValue(_) => "TypeError",
×
763
  }
764
}
×
765

766
fn get_fs_ops_error(error: &FsOpsError) -> &'static str {
1✔
767
  use FsOpsErrorKind::*;
768
  match error.as_kind() {
1✔
769
    Io(e) => get_io_error_class(e),
×
770
    OperationError(e) => get_fs_error(&e.err),
1✔
771
    Permission(e) => get_permission_check_error_class(e),
×
772
    Resource(e) | Other(e) => get_error_class_name(e).unwrap_or("Error"),
×
773
    InvalidUtf8(_) => "InvalidData",
×
774
    StripPrefix(_) => "Error",
×
775
    Canceled(e) => {
×
776
      let io_err: io::Error = e.to_owned().into();
×
777
      get_io_error_class(&io_err)
×
778
    }
779
    InvalidSeekMode(_) => "TypeError",
×
780
    InvalidControlCharacter(_) => "Error",
×
781
    InvalidCharacter(_) => "Error",
×
782
    #[cfg(windows)]
783
    InvalidTrailingCharacter => "Error",
784
    NotCapableAccess { .. } => "NotCapable",
×
785
    NotCapable(_) => "NotCapable",
×
786
  }
787
}
1✔
788

789
// fn get_kv_error(error: &KvError) -> &'static str {
790
//   use KvErrorKind::*;
791
//   match error.as_kind() {
792
//     DatabaseHandler(e) | Resource(e) | Kv(e) => {
793
//       get_error_class_name(e).unwrap_or("Error")
794
//     }
795
//     TooManyRanges(_) => "TypeError",
796
//     TooManyEntries(_) => "TypeError",
797
//     TooManyChecks(_) => "TypeError",
798
//     TooManyMutations(_) => "TypeError",
799
//     TooManyKeys(_) => "TypeError",
800
//     InvalidLimit => "TypeError",
801
//     InvalidBoundaryKey => "TypeError",
802
//     KeyTooLargeToRead(_) => "TypeError",
803
//     KeyTooLargeToWrite(_) => "TypeError",
804
//     TotalMutationTooLarge(_) => "TypeError",
805
//     TotalKeyTooLarge(_) => "TypeError",
806
//     Io(e) => get_io_error_class(e),
807
//     QueueMessageNotFound => "TypeError",
808
//     StartKeyNotInKeyspace => "TypeError",
809
//     EndKeyNotInKeyspace => "TypeError",
810
//     StartKeyGreaterThanEndKey => "TypeError",
811
//     InvalidCheck(e) => match e {
812
//       KvCheckError::InvalidVersionstamp => "TypeError",
813
//       KvCheckError::Io(e) => get_io_error_class(e),
814
//     },
815
//     InvalidMutation(e) => match e {
816
//       KvMutationError::BigInt(_) => "Error",
817
//       KvMutationError::Io(e) => get_io_error_class(e),
818
//       KvMutationError::InvalidMutationWithValue(_) => "TypeError",
819
//       KvMutationError::InvalidMutationWithoutValue(_) => "TypeError",
820
//     },
821
//     InvalidEnqueue(e) => get_io_error_class(e),
822
//     EmptyKey => "TypeError",
823
//     ValueTooLarge(_) => "TypeError",
824
//     EnqueuePayloadTooLarge(_) => "TypeError",
825
//     InvalidCursor => "TypeError",
826
//     CursorOutOfBounds => "TypeError",
827
//     InvalidRange => "TypeError",
828
//   }
829
// }
830

831
fn get_net_error(error: &NetError) -> &'static str {
1✔
832
  match error {
1✔
833
    NetError::ListenerClosed => "BadResource",
×
834
    NetError::ListenerBusy => "Busy",
×
835
    NetError::SocketClosed => "BadResource",
×
836
    NetError::SocketClosedNotConnected => "NotConnected",
×
837
    NetError::SocketBusy => "Busy",
×
838
    NetError::Io(e) => get_io_error_class(e),
1✔
839
    NetError::AcceptTaskOngoing => "Busy",
×
840
    NetError::RootCertStore(e) | NetError::Resource(e) => {
×
841
      get_error_class_name(e).unwrap_or("Error")
×
842
    }
843
    NetError::Permission(e) => get_permission_check_error_class(e),
×
844
    NetError::NoResolvedAddress => "Error",
×
845
    NetError::AddrParse(_) => "Error",
×
846
    NetError::Map(e) => get_net_map_error(e),
×
847
    NetError::Canceled(e) => {
×
848
      let io_err: io::Error = e.to_owned().into();
×
849
      get_io_error_class(&io_err)
×
850
    }
851
    NetError::DnsNotFound(_) => "NotFound",
×
852
    NetError::DnsNotConnected(_) => "NotConnected",
×
853
    NetError::DnsTimedOut(_) => "TimedOut",
×
854
    NetError::Dns(_) => "Error",
×
855
    NetError::UnsupportedRecordType => "NotSupported",
×
856
    NetError::InvalidUtf8(_) => "InvalidData",
×
857
    NetError::UnexpectedKeyType => "Error",
×
858
    NetError::InvalidHostname(_) => "TypeError",
×
859
    NetError::TcpStreamBusy => "Busy",
×
860
    NetError::Rustls(_) => "Error",
×
861
    NetError::Tls(e) => get_tls_error_class(e),
×
862
    NetError::ListenTlsRequiresKey => "InvalidData",
×
863
    NetError::Reunite(_) => "Error",
×
864
  }
865
}
1✔
866

867
fn get_net_map_error(error: &deno_net::io::MapError) -> &'static str {
×
868
  match error {
×
869
    deno_net::io::MapError::Io(e) => get_io_error_class(e),
×
870
    deno_net::io::MapError::NoResources => "Error",
×
871
  }
872
}
×
873

874
fn get_child_permission_error(e: &ChildPermissionError) -> &'static str {
×
875
  match e {
×
876
    ChildPermissionError::Escalation => "NotCapable",
×
877
    ChildPermissionError::PathResolve(e) => get_path_resolve_error(e),
×
878
    ChildPermissionError::NetDescriptorParse(_) => "URIError",
×
879
    ChildPermissionError::EnvDescriptorParse(_) => "Error",
×
880
    ChildPermissionError::SysDescriptorParse(e) => {
×
881
      get_sys_descriptor_parse_error(e)
×
882
    }
883
    ChildPermissionError::RunDescriptorParse(e) => {
×
884
      get_run_descriptor_parse_error(e)
×
885
    }
886
  }
887
}
×
888

889
// fn get_create_worker_error(error: &CreateWorkerError) -> &'static str {
890
//   match error {
891
//     CreateWorkerError::ClassicWorkers => "DOMExceptionNotSupportedError",
892
//     CreateWorkerError::Permission(e) => get_child_permission_error(e),
893
//     CreateWorkerError::ModuleResolution(e) => {
894
//       get_module_resolution_error_class(e)
895
//     }
896
//     CreateWorkerError::Io(e) => get_io_error_class(e),
897
//     CreateWorkerError::MessagePort(e) => get_web_message_port_error_class(e),
898
//   }
899
// }
900

901
// fn get_tty_error(error: &TtyError) -> &'static str {
902
//   match error {
903
//     TtyError::Resource(e) | TtyError::Other(e) => {
904
//       get_error_class_name(e).unwrap_or("Error")
905
//     }
906
//     TtyError::Io(e) => get_io_error_class(e),
907
//     #[cfg(unix)]
908
//     TtyError::Nix(e) => get_nix_error_class(e),
909
//   }
910
// }
911

912
// fn get_readline_error(error: &ReadlineError) -> &'static str {
913
//   match error {
914
//     ReadlineError::Io(e) => get_io_error_class(e),
915
//     ReadlineError::Eof => "Error",
916
//     ReadlineError::Interrupted => "Error",
917
//     #[cfg(unix)]
918
//     ReadlineError::Errno(e) => get_nix_error_class(e),
919
//     ReadlineError::WindowResized => "Error",
920
//     #[cfg(windows)]
921
//     ReadlineError::Decode(_) => "Error",
922
//     #[cfg(windows)]
923
//     ReadlineError::SystemError(_) => "Error",
924
//     _ => "Error",
925
//   }
926
// }
927

928
// fn get_signal_error(error: &SignalError) -> &'static str {
929
//   match error {
930
//     SignalError::InvalidSignalStr(_) => "TypeError",
931
//     SignalError::InvalidSignalInt(_) => "TypeError",
932
//     SignalError::SignalNotAllowed(_) => "TypeError",
933
//     SignalError::Io(e) => get_io_error_class(e),
934
//   }
935
// }
936

937
// fn get_fs_events_error(error: &FsEventsError) -> &'static str {
938
//   match error {
939
//     FsEventsError::Resource(e) => get_error_class_name(e).unwrap_or("Error"),
940
//     FsEventsError::Permission(e) => get_permission_check_error_class(e),
941
//     FsEventsError::Notify(e) => get_notify_error_class(e),
942
//     FsEventsError::Canceled(e) => {
943
//       let io_err: io::Error = e.to_owned().into();
944
//       get_io_error_class(&io_err)
945
//     }
946
//   }
947
// }
948

949
// fn get_http_start_error(error: &HttpStartError) -> &'static str {
950
//   match error {
951
//     HttpStartError::TcpStreamInUse => "Busy",
952
//     HttpStartError::TlsStreamInUse => "Busy",
953
//     HttpStartError::UnixSocketInUse => "Busy",
954
//     HttpStartError::ReuniteTcp(_) => "Error",
955
//     #[cfg(unix)]
956
//     HttpStartError::ReuniteUnix(_) => "Error",
957
//     HttpStartError::Io(e) => get_io_error_class(e),
958
//     HttpStartError::Other(e) => get_error_class_name(e).unwrap_or("Error"),
959
//   }
960
// }
961

962
// fn get_process_error(error: &ProcessError) -> &'static str {
963
//   match error {
964
//     ProcessError::SpawnFailed { error, .. } => get_process_error(error),
965
//     ProcessError::FailedResolvingCwd(e) | ProcessError::Io(e) => {
966
//       get_io_error_class(e)
967
//     }
968
//     ProcessError::Permission(e) => get_permission_check_error_class(e),
969
//     ProcessError::Resource(e) => get_error_class_name(e).unwrap_or("Error"),
970
//     ProcessError::BorrowMut(_) => "Error",
971
//     ProcessError::Which(_) => "Error",
972
//     ProcessError::ChildProcessAlreadyTerminated => "TypeError",
973
//     ProcessError::Signal(e) => get_signal_error(e),
974
//     ProcessError::MissingCmd => "Error",
975
//     ProcessError::InvalidPid => "TypeError",
976
//     #[cfg(unix)]
977
//     ProcessError::Nix(e) => get_nix_error_class(e),
978
//     ProcessError::RunPermission(e) => match e {
979
//       CheckRunPermissionError::Permission(e) => {
980
//         get_permission_check_error_class(e)
981
//       }
982
//       CheckRunPermissionError::Other(e) => {
983
//         get_error_class_name(e).unwrap_or("Error")
984
//       }
985
//     },
986
//   }
987
// }
988

989
fn get_http_error(error: &HttpError) -> &'static str {
23✔
990
  match error {
23✔
991
    HttpError::Canceled(e) => {
11✔
992
      let io_err: io::Error = e.to_owned().into();
11✔
993
      get_io_error_class(&io_err)
11✔
994
    }
995
    HttpError::HyperV014(e) => get_hyper_v014_error_class(e),
10✔
996
    HttpError::InvalidHeaderName(_) => "Error",
×
997
    HttpError::InvalidHeaderValue(_) => "Error",
×
998
    HttpError::Http(_) => "Error",
×
999
    HttpError::ResponseHeadersAlreadySent => "Http",
×
1000
    HttpError::ConnectionClosedWhileSendingResponse => "Http",
×
1001
    HttpError::AlreadyInUse => "Http",
×
1002
    HttpError::Io(e) => get_io_error_class(e),
×
1003
    HttpError::NoResponseHeaders => "Http",
×
1004
    HttpError::ResponseAlreadyCompleted => "Http",
×
1005
    HttpError::UpgradeBodyUsed => "Http",
×
1006
    HttpError::Resource(e) | HttpError::Other(e) => {
2✔
1007
      get_error_class_name(e).unwrap_or("Error")
2✔
1008
    }
1009
  }
1010
}
23✔
1011

1012
fn get_http_next_error(error: &HttpNextError) -> &'static str {
×
1013
  match error {
×
1014
    HttpNextError::Io(e) => get_io_error_class(e),
×
1015
    HttpNextError::WebSocketUpgrade(e) => get_websocket_upgrade_error(e),
×
1016
    HttpNextError::Hyper(e) => get_hyper_error_class(e),
×
1017
    HttpNextError::JoinError(_) => "Error",
×
1018
    HttpNextError::Canceled(e) => {
×
1019
      let io_err: io::Error = e.to_owned().into();
×
1020
      get_io_error_class(&io_err)
×
1021
    }
1022
    HttpNextError::UpgradeUnavailable(_) => "Error",
×
1023
    HttpNextError::HttpPropertyExtractor(e) | HttpNextError::Resource(e) => {
×
1024
      get_error_class_name(e).unwrap_or("Error")
×
1025
    }
1026
  }
1027
}
×
1028

1029
fn get_websocket_upgrade_error(error: &WebSocketUpgradeError) -> &'static str {
×
1030
  match error {
×
1031
    WebSocketUpgradeError::InvalidHeaders => "Http",
×
1032
    WebSocketUpgradeError::HttpParse(_) => "Error",
×
1033
    WebSocketUpgradeError::Http(_) => "Error",
×
1034
    WebSocketUpgradeError::Utf8(_) => "Error",
×
1035
    WebSocketUpgradeError::InvalidHeaderName(_) => "Error",
×
1036
    WebSocketUpgradeError::InvalidHeaderValue(_) => "Error",
×
1037
    WebSocketUpgradeError::InvalidHttpStatusLine => "Http",
×
1038
    WebSocketUpgradeError::UpgradeBufferAlreadyCompleted => "Http",
×
1039
  }
1040
}
×
1041

1042
fn get_fs_error(e: &FsError) -> &'static str {
1✔
1043
  match &e {
1✔
1044
    FsError::Io(e) => get_io_error_class(e),
1✔
1045
    FsError::FileBusy => "Busy",
×
1046
    FsError::NotSupported => "NotSupported",
×
1047
    FsError::NotCapable(_) => "NotCapable",
×
1048
  }
1049
}
1✔
1050

1051
mod node {
1052
  use super::get_error_class_name;
1053
  use super::get_io_error_class;
1054
  use super::get_permission_check_error_class;
1055
  use super::get_serde_json_error_class;
1056
  use super::get_url_parse_error_class;
1057
  pub use ext_node::ops::blocklist::BlocklistError;
1058
  pub use ext_node::ops::crypto::cipher::CipherContextError;
1059
  pub use ext_node::ops::crypto::cipher::CipherError;
1060
  pub use ext_node::ops::crypto::cipher::DecipherContextError;
1061
  pub use ext_node::ops::crypto::cipher::DecipherError;
1062
  pub use ext_node::ops::crypto::digest::HashError;
1063
  pub use ext_node::ops::crypto::keys::AsymmetricPrivateKeyDerError;
1064
  pub use ext_node::ops::crypto::keys::AsymmetricPrivateKeyError;
1065
  pub use ext_node::ops::crypto::keys::AsymmetricPublicKeyDerError;
1066
  pub use ext_node::ops::crypto::keys::AsymmetricPublicKeyError;
1067
  pub use ext_node::ops::crypto::keys::AsymmetricPublicKeyJwkError;
1068
  pub use ext_node::ops::crypto::keys::EcJwkError;
1069
  pub use ext_node::ops::crypto::keys::EdRawError;
1070
  pub use ext_node::ops::crypto::keys::ExportPrivateKeyPemError;
1071
  pub use ext_node::ops::crypto::keys::ExportPublicKeyPemError;
1072
  pub use ext_node::ops::crypto::keys::GenerateRsaPssError;
1073
  pub use ext_node::ops::crypto::keys::RsaJwkError;
1074
  pub use ext_node::ops::crypto::keys::RsaPssParamsParseError;
1075
  pub use ext_node::ops::crypto::keys::X509PublicKeyError;
1076
  pub use ext_node::ops::crypto::sign::KeyObjectHandlePrehashedSignAndVerifyError;
1077
  pub use ext_node::ops::crypto::x509::X509Error;
1078
  pub use ext_node::ops::crypto::DiffieHellmanError;
1079
  pub use ext_node::ops::crypto::EcdhEncodePubKey;
1080
  pub use ext_node::ops::crypto::HkdfError;
1081
  pub use ext_node::ops::crypto::Pbkdf2Error;
1082
  pub use ext_node::ops::crypto::PrivateEncryptDecryptError;
1083
  pub use ext_node::ops::crypto::ScryptAsyncError;
1084
  pub use ext_node::ops::crypto::SignEd25519Error;
1085
  pub use ext_node::ops::crypto::VerifyEd25519Error;
1086
  pub use ext_node::ops::fs::FsError;
1087
  pub use ext_node::ops::http2::Http2Error;
1088
  pub use ext_node::ops::idna::IdnaError;
1089
  pub use ext_node::ops::ipc::IpcError;
1090
  pub use ext_node::ops::ipc::IpcJsonStreamError;
1091
  use ext_node::ops::os::priority::PriorityError;
1092
  pub use ext_node::ops::os::OsError;
1093
  pub use ext_node::ops::require::RequireError;
1094
  use ext_node::ops::require::RequireErrorKind;
1095
  pub use ext_node::ops::worker_threads::WorkerThreadsFilenameError;
1096
  pub use ext_node::ops::zlib::brotli::BrotliError;
1097
  pub use ext_node::ops::zlib::mode::ModeError;
1098
  pub use ext_node::ops::zlib::ZlibError;
1099

1100
  pub fn get_blocklist_error(error: &BlocklistError) -> &'static str {
×
1101
    match error {
×
1102
      BlocklistError::AddrParse(_) => "Error",
×
1103
      BlocklistError::IpNetwork(_) => "Error",
×
1104
      BlocklistError::InvalidAddress => "Error",
×
1105
      BlocklistError::IpVersionMismatch => "Error",
×
1106
    }
1107
  }
×
1108

1109
  pub fn get_fs_error(error: &FsError) -> &'static str {
×
1110
    match error {
×
1111
      FsError::Permission(e) => get_permission_check_error_class(e),
×
1112
      FsError::Io(e) => get_io_error_class(e),
×
1113
      #[cfg(windows)]
1114
      FsError::PathHasNoRoot => "Error",
1115
      #[cfg(not(any(unix, windows)))]
1116
      FsError::UnsupportedPlatform => "Error",
1117
      FsError::Fs(e) => super::get_fs_error(e),
×
1118
    }
1119
  }
×
1120

1121
  pub fn get_idna_error(error: &IdnaError) -> &'static str {
×
1122
    match error {
×
1123
      IdnaError::InvalidInput => "RangeError",
×
1124
      IdnaError::InputTooLong => "Error",
×
1125
      IdnaError::IllegalInput => "RangeError",
×
1126
    }
1127
  }
×
1128

1129
  pub fn get_ipc_json_stream_error(error: &IpcJsonStreamError) -> &'static str {
×
1130
    match error {
×
1131
      IpcJsonStreamError::Io(e) => get_io_error_class(e),
×
1132
      IpcJsonStreamError::SimdJson(_) => "Error",
×
1133
    }
1134
  }
×
1135

1136
  pub fn get_ipc_error(error: &IpcError) -> &'static str {
×
1137
    match error {
×
1138
      IpcError::Resource(e) => get_error_class_name(e).unwrap_or("Error"),
×
1139
      IpcError::IpcJsonStream(e) => get_ipc_json_stream_error(e),
×
1140
      IpcError::Canceled(e) => {
×
1141
        let io_err: std::io::Error = e.to_owned().into();
×
1142
        get_io_error_class(&io_err)
×
1143
      }
1144
      IpcError::SerdeJson(e) => get_serde_json_error_class(e),
×
1145
    }
1146
  }
×
1147

1148
  pub fn get_worker_threads_filename_error(
×
1149
    error: &WorkerThreadsFilenameError,
×
1150
  ) -> &'static str {
×
1151
    match error {
×
1152
      WorkerThreadsFilenameError::Permission(e) => {
×
1153
        get_error_class_name(e).unwrap_or("Error")
×
1154
      }
1155
      WorkerThreadsFilenameError::UrlParse(e) => get_url_parse_error_class(e),
×
1156
      WorkerThreadsFilenameError::InvalidRelativeUrl => "Error",
×
1157
      WorkerThreadsFilenameError::UrlFromPathString => "Error",
×
1158
      WorkerThreadsFilenameError::UrlToPathString => "Error",
×
1159
      WorkerThreadsFilenameError::UrlToPath => "Error",
×
1160
      WorkerThreadsFilenameError::FileNotFound(_) => "Error",
×
1161
      WorkerThreadsFilenameError::Fs(e) => super::get_fs_error(e),
×
1162
    }
1163
  }
×
1164

1165
  pub fn get_require_error(error: &RequireError) -> &'static str {
×
1166
    use RequireErrorKind::*;
1167
    match error.as_kind() {
×
1168
      UrlParse(e) => get_url_parse_error_class(e),
×
1169
      Permission(e) => get_error_class_name(e).unwrap_or("Error"),
×
1170
      PackageExportsResolve(_)
1171
      | PackageJsonLoad(_)
1172
      | ClosestPkgJson(_)
1173
      | FilePathConversion(_)
1174
      | UrlConversion(_)
1175
      | ReadModule(_)
1176
      | PackageImportsResolve(_) => "Error",
×
1177
      Fs(e) | UnableToGetCwd(e) => super::get_fs_error(e),
×
1178
    }
1179
  }
×
1180

1181
  pub fn get_http2_error(error: &Http2Error) -> &'static str {
×
1182
    match error {
×
1183
      Http2Error::Resource(e) => get_error_class_name(e).unwrap_or("Error"),
×
1184
      Http2Error::UrlParse(e) => get_url_parse_error_class(e),
×
1185
      Http2Error::H2(_) => "Error",
×
1186
    }
1187
  }
×
1188

1189
  pub fn get_os_error(error: &OsError) -> &'static str {
×
1190
    match error {
×
1191
      OsError::Priority(e) => match e {
×
1192
        PriorityError::Io(e) => get_io_error_class(e),
×
1193
        #[cfg(windows)]
1194
        PriorityError::InvalidPriority => "TypeError",
1195
      },
1196
      OsError::Permission(e) => get_permission_check_error_class(e),
×
1197
      OsError::FailedToGetCpuInfo => "TypeError",
×
1198
      OsError::FailedToGetUserInfo(e) => get_io_error_class(e),
×
1199
    }
1200
  }
×
1201

1202
  pub fn get_brotli_error(error: &BrotliError) -> &'static str {
×
1203
    match error {
×
1204
      BrotliError::InvalidEncoderMode => "TypeError",
×
1205
      BrotliError::CompressFailed => "TypeError",
×
1206
      BrotliError::DecompressFailed => "TypeError",
×
1207
      BrotliError::Join(_) => "Error",
×
1208
      BrotliError::Resource(e) => get_error_class_name(e).unwrap_or("Error"),
×
1209
      BrotliError::Io(e) => get_io_error_class(e),
×
1210
    }
1211
  }
×
1212

1213
  pub fn get_mode_error(_: &ModeError) -> &'static str {
×
1214
    "Error"
×
1215
  }
×
1216

1217
  pub fn get_zlib_error(e: &ZlibError) -> &'static str {
×
1218
    match e {
×
1219
      ZlibError::NotInitialized => "TypeError",
×
1220
      ZlibError::Mode(e) => get_mode_error(e),
×
1221
      ZlibError::Other(e) => get_error_class_name(e).unwrap_or("Error"),
×
1222
    }
1223
  }
×
1224

1225
  pub fn get_crypto_cipher_context_error(
×
1226
    e: &CipherContextError,
×
1227
  ) -> &'static str {
×
1228
    match e {
×
1229
      CipherContextError::ContextInUse => "TypeError",
×
1230
      CipherContextError::Cipher(e) => get_crypto_cipher_error(e),
×
1231
      CipherContextError::Resource(e) => {
×
1232
        get_error_class_name(e).unwrap_or("Error")
×
1233
      }
1234
    }
1235
  }
×
1236

1237
  pub fn get_crypto_cipher_error(e: &CipherError) -> &'static str {
×
1238
    match e {
×
1239
      CipherError::InvalidIvLength => "TypeError",
×
1240
      CipherError::InvalidKeyLength => "RangeError",
×
1241
      CipherError::InvalidInitializationVector => "TypeError",
×
1242
      CipherError::CannotPadInputData => "TypeError",
×
1243
      CipherError::UnknownCipher(_) => "TypeError",
×
1244
    }
1245
  }
×
1246

1247
  pub fn get_crypto_decipher_context_error(
×
1248
    e: &DecipherContextError,
×
1249
  ) -> &'static str {
×
1250
    match e {
×
1251
      DecipherContextError::ContextInUse => "TypeError",
×
1252
      DecipherContextError::Decipher(e) => get_crypto_decipher_error(e),
×
1253
      DecipherContextError::Resource(e) => {
×
1254
        get_error_class_name(e).unwrap_or("Error")
×
1255
      }
1256
    }
1257
  }
×
1258

1259
  pub fn get_crypto_decipher_error(e: &DecipherError) -> &'static str {
×
1260
    match e {
×
1261
      DecipherError::InvalidIvLength => "TypeError",
×
1262
      DecipherError::InvalidKeyLength => "RangeError",
×
1263
      DecipherError::InvalidInitializationVector => "TypeError",
×
1264
      DecipherError::CannotUnpadInputData => "TypeError",
×
1265
      DecipherError::DataAuthenticationFailed => "TypeError",
×
1266
      DecipherError::SetAutoPaddingFalseAes128GcmUnsupported => "TypeError",
×
1267
      DecipherError::SetAutoPaddingFalseAes256GcmUnsupported => "TypeError",
×
1268
      DecipherError::UnknownCipher(_) => "TypeError",
×
1269
    }
1270
  }
×
1271

1272
  pub fn get_x509_error(_: &X509Error) -> &'static str {
×
1273
    "Error"
×
1274
  }
×
1275

1276
  pub fn get_crypto_key_object_handle_prehashed_sign_and_verify_error(
×
1277
    e: &KeyObjectHandlePrehashedSignAndVerifyError,
×
1278
  ) -> &'static str {
×
1279
    match e {
×
1280
      KeyObjectHandlePrehashedSignAndVerifyError::InvalidDsaSignatureEncoding => "TypeError",
×
1281
      KeyObjectHandlePrehashedSignAndVerifyError::KeyIsNotPrivate => "TypeError",
×
1282
      KeyObjectHandlePrehashedSignAndVerifyError::DigestNotAllowedForRsaSignature(_) => "TypeError",
×
1283
      KeyObjectHandlePrehashedSignAndVerifyError::FailedToSignDigestWithRsa => "Error",
×
1284
      KeyObjectHandlePrehashedSignAndVerifyError::DigestNotAllowedForRsaPssSignature(_) => "TypeError",
×
1285
      KeyObjectHandlePrehashedSignAndVerifyError::FailedToSignDigestWithRsaPss => "Error",
×
1286
      KeyObjectHandlePrehashedSignAndVerifyError::FailedToSignDigestWithDsa => "TypeError",
×
1287
      KeyObjectHandlePrehashedSignAndVerifyError::RsaPssHashAlgorithmUnsupported => "TypeError",
×
1288
      KeyObjectHandlePrehashedSignAndVerifyError::PrivateKeyDisallowsUsage { .. } => "TypeError",
×
1289
      KeyObjectHandlePrehashedSignAndVerifyError::FailedToSignDigest => "TypeError",
×
1290
      KeyObjectHandlePrehashedSignAndVerifyError::X25519KeyCannotBeUsedForSigning => "TypeError",
×
1291
      KeyObjectHandlePrehashedSignAndVerifyError::Ed25519KeyCannotBeUsedForPrehashedSigning => "TypeError",
×
1292
      KeyObjectHandlePrehashedSignAndVerifyError::DhKeyCannotBeUsedForSigning => "TypeError",
×
1293
      KeyObjectHandlePrehashedSignAndVerifyError::KeyIsNotPublicOrPrivate => "TypeError",
×
1294
      KeyObjectHandlePrehashedSignAndVerifyError::InvalidDsaSignature => "TypeError",
×
1295
      KeyObjectHandlePrehashedSignAndVerifyError::X25519KeyCannotBeUsedForVerification => "TypeError",
×
1296
      KeyObjectHandlePrehashedSignAndVerifyError::Ed25519KeyCannotBeUsedForPrehashedVerification => "TypeError",
×
1297
      KeyObjectHandlePrehashedSignAndVerifyError::DhKeyCannotBeUsedForVerification => "TypeError",
×
1298
    }
1299
  }
×
1300

1301
  pub fn get_crypto_hash_error(_: &HashError) -> &'static str {
×
1302
    "Error"
×
1303
  }
×
1304

1305
  pub fn get_asymmetric_public_key_jwk_error(
×
1306
    e: &AsymmetricPublicKeyJwkError,
×
1307
  ) -> &'static str {
×
1308
    match e {
×
1309
      AsymmetricPublicKeyJwkError::UnsupportedJwkEcCurveP224 => "TypeError",
×
1310
      AsymmetricPublicKeyJwkError::JwkExportNotImplementedForKeyType => {
1311
        "TypeError"
×
1312
      }
1313
      AsymmetricPublicKeyJwkError::KeyIsNotAsymmetricPublicKey => "TypeError",
×
1314
    }
1315
  }
×
1316

1317
  pub fn get_generate_rsa_pss_error(_: &GenerateRsaPssError) -> &'static str {
×
1318
    "TypeError"
×
1319
  }
×
1320

1321
  pub fn get_asymmetric_private_key_der_error(
×
1322
    e: &AsymmetricPrivateKeyDerError,
×
1323
  ) -> &'static str {
×
1324
    match e {
×
1325
      AsymmetricPrivateKeyDerError::KeyIsNotAsymmetricPrivateKey => "TypeError",
×
1326
      AsymmetricPrivateKeyDerError::InvalidRsaPrivateKey => "TypeError",
×
1327
      AsymmetricPrivateKeyDerError::ExportingNonRsaPrivateKeyAsPkcs1Unsupported => "TypeError",
×
1328
      AsymmetricPrivateKeyDerError::InvalidEcPrivateKey => "TypeError",
×
1329
      AsymmetricPrivateKeyDerError::ExportingNonEcPrivateKeyAsSec1Unsupported => "TypeError",
×
1330
      AsymmetricPrivateKeyDerError::ExportingNonRsaPssPrivateKeyAsPkcs8Unsupported => "Error",
×
1331
      AsymmetricPrivateKeyDerError::InvalidDsaPrivateKey => "TypeError",
×
1332
      AsymmetricPrivateKeyDerError::InvalidX25519PrivateKey => "TypeError",
×
1333
      AsymmetricPrivateKeyDerError::InvalidEd25519PrivateKey => "TypeError",
×
1334
      AsymmetricPrivateKeyDerError::InvalidDhPrivateKey => "TypeError",
×
1335
      AsymmetricPrivateKeyDerError::UnsupportedKeyType(_) => "TypeError",
×
1336
    }
1337
  }
×
1338

1339
  pub fn get_asymmetric_public_key_der_error(
×
1340
    _: &AsymmetricPublicKeyDerError,
×
1341
  ) -> &'static str {
×
1342
    "TypeError"
×
1343
  }
×
1344

1345
  pub fn get_export_public_key_pem_error(
×
1346
    e: &ExportPublicKeyPemError,
×
1347
  ) -> &'static str {
×
1348
    match e {
×
1349
      ExportPublicKeyPemError::AsymmetricPublicKeyDer(e) => {
×
1350
        get_asymmetric_public_key_der_error(e)
×
1351
      }
1352
      ExportPublicKeyPemError::VeryLargeData => "TypeError",
×
1353
      ExportPublicKeyPemError::Der(_) => "Error",
×
1354
    }
1355
  }
×
1356

1357
  pub fn get_export_private_key_pem_error(
×
1358
    e: &ExportPrivateKeyPemError,
×
1359
  ) -> &'static str {
×
1360
    match e {
×
1361
      ExportPrivateKeyPemError::AsymmetricPublicKeyDer(e) => {
×
1362
        get_asymmetric_private_key_der_error(e)
×
1363
      }
1364
      ExportPrivateKeyPemError::VeryLargeData => "TypeError",
×
1365
      ExportPrivateKeyPemError::Der(_) => "Error",
×
1366
    }
1367
  }
×
1368

1369
  pub fn get_x509_public_key_error(e: &X509PublicKeyError) -> &'static str {
×
1370
    match e {
×
1371
      X509PublicKeyError::X509(_) => "Error",
×
1372
      X509PublicKeyError::Rsa(_) => "Error",
×
1373
      X509PublicKeyError::Asn1(_) => "Error",
×
1374
      X509PublicKeyError::Ec(_) => "Error",
×
1375
      X509PublicKeyError::UnsupportedEcNamedCurve => "TypeError",
×
1376
      X509PublicKeyError::MissingEcParameters => "TypeError",
×
1377
      X509PublicKeyError::MalformedDssPublicKey => "TypeError",
×
1378
      X509PublicKeyError::UnsupportedX509KeyType => "TypeError",
×
1379
    }
1380
  }
×
1381

1382
  pub fn get_rsa_jwk_error(e: &RsaJwkError) -> &'static str {
×
1383
    match e {
×
1384
      RsaJwkError::Base64(_) => "Error",
×
1385
      RsaJwkError::Rsa(_) => "Error",
×
1386
      RsaJwkError::MissingRsaPrivateComponent => "TypeError",
×
1387
    }
1388
  }
×
1389

1390
  pub fn get_ec_jwk_error(e: &EcJwkError) -> &'static str {
×
1391
    match e {
×
1392
      EcJwkError::Ec(_) => "Error",
×
1393
      EcJwkError::UnsupportedCurve(_) => "TypeError",
×
1394
    }
1395
  }
×
1396

1397
  pub fn get_ed_raw_error(e: &EdRawError) -> &'static str {
×
1398
    match e {
×
1399
      EdRawError::Ed25519Signature(_) => "Error",
×
1400
      EdRawError::InvalidEd25519Key => "TypeError",
×
1401
      EdRawError::UnsupportedCurve => "TypeError",
×
1402
    }
1403
  }
×
1404

1405
  pub fn get_pbkdf2_error(e: &Pbkdf2Error) -> &'static str {
×
1406
    match e {
×
1407
      Pbkdf2Error::UnsupportedDigest(_) => "TypeError",
×
1408
      Pbkdf2Error::Join(_) => "Error",
×
1409
    }
1410
  }
×
1411

1412
  pub fn get_scrypt_async_error(e: &ScryptAsyncError) -> &'static str {
×
1413
    match e {
×
1414
      ScryptAsyncError::Join(_) => "Error",
×
1415
      ScryptAsyncError::Other(e) => get_error_class_name(e).unwrap_or("Error"),
×
1416
    }
1417
  }
×
1418

1419
  pub fn get_hkdf_error_error(e: &HkdfError) -> &'static str {
×
1420
    match e {
×
1421
      HkdfError::ExpectedSecretKey => "TypeError",
×
1422
      HkdfError::HkdfExpandFailed => "TypeError",
×
1423
      HkdfError::UnsupportedDigest(_) => "TypeError",
×
1424
      HkdfError::Join(_) => "Error",
×
1425
    }
1426
  }
×
1427

1428
  pub fn get_rsa_pss_params_parse_error(
×
1429
    _: &RsaPssParamsParseError,
×
1430
  ) -> &'static str {
×
1431
    "TypeError"
×
1432
  }
×
1433

1434
  pub fn get_asymmetric_private_key_error(
×
1435
    e: &AsymmetricPrivateKeyError,
×
1436
  ) -> &'static str {
×
1437
    match e {
×
1438
      AsymmetricPrivateKeyError::InvalidPemPrivateKeyInvalidUtf8(_) => "TypeError",
×
1439
      AsymmetricPrivateKeyError::InvalidEncryptedPemPrivateKey => "TypeError",
×
1440
      AsymmetricPrivateKeyError::InvalidPemPrivateKey => "TypeError",
×
1441
      AsymmetricPrivateKeyError::EncryptedPrivateKeyRequiresPassphraseToDecrypt => "TypeError",
×
1442
      AsymmetricPrivateKeyError::InvalidPkcs1PrivateKey => "TypeError",
×
1443
      AsymmetricPrivateKeyError::InvalidSec1PrivateKey => "TypeError",
×
1444
      AsymmetricPrivateKeyError::UnsupportedPemLabel(_) => "TypeError",
×
1445
      AsymmetricPrivateKeyError::RsaPssParamsParse(e) => get_rsa_pss_params_parse_error(e),
×
1446
      AsymmetricPrivateKeyError::InvalidEncryptedPkcs8PrivateKey => "TypeError",
×
1447
      AsymmetricPrivateKeyError::InvalidPkcs8PrivateKey => "TypeError",
×
1448
      AsymmetricPrivateKeyError::Pkcs1PrivateKeyDoesNotSupportEncryptionWithPassphrase => "TypeError",
×
1449
      AsymmetricPrivateKeyError::Sec1PrivateKeyDoesNotSupportEncryptionWithPassphrase => "TypeError",
×
1450
      AsymmetricPrivateKeyError::UnsupportedEcNamedCurve => "TypeError",
×
1451
      AsymmetricPrivateKeyError::InvalidPrivateKey => "TypeError",
×
1452
      AsymmetricPrivateKeyError::InvalidDsaPrivateKey => "TypeError",
×
1453
      AsymmetricPrivateKeyError::MalformedOrMissingNamedCurveInEcParameters => "TypeError",
×
1454
      AsymmetricPrivateKeyError::UnsupportedKeyType(_) => "TypeError",
×
1455
      AsymmetricPrivateKeyError::UnsupportedKeyFormat(_) => "TypeError",
×
1456
      AsymmetricPrivateKeyError::InvalidX25519PrivateKey => "TypeError",
×
1457
      AsymmetricPrivateKeyError::X25519PrivateKeyIsWrongLength => "TypeError",
×
1458
      AsymmetricPrivateKeyError::InvalidEd25519PrivateKey => "TypeError",
×
1459
      AsymmetricPrivateKeyError::MissingDhParameters => "TypeError",
×
1460
      AsymmetricPrivateKeyError::UnsupportedPrivateKeyOid => "TypeError",
×
1461
    }
1462
  }
×
1463

1464
  pub fn get_asymmetric_public_key_error(
×
1465
    e: &AsymmetricPublicKeyError,
×
1466
  ) -> &'static str {
×
1467
    match e {
×
1468
      AsymmetricPublicKeyError::InvalidPemPrivateKeyInvalidUtf8(_) => {
1469
        "TypeError"
×
1470
      }
1471
      AsymmetricPublicKeyError::InvalidPemPublicKey => "TypeError",
×
1472
      AsymmetricPublicKeyError::InvalidPkcs1PublicKey => "TypeError",
×
1473
      AsymmetricPublicKeyError::AsymmetricPrivateKey(e) => {
×
1474
        get_asymmetric_private_key_error(e)
×
1475
      }
1476
      AsymmetricPublicKeyError::InvalidX509Certificate => "TypeError",
×
1477
      AsymmetricPublicKeyError::X509(_) => "Error",
×
1478
      AsymmetricPublicKeyError::X509PublicKey(e) => {
×
1479
        get_x509_public_key_error(e)
×
1480
      }
1481
      AsymmetricPublicKeyError::UnsupportedPemLabel(_) => "TypeError",
×
1482
      AsymmetricPublicKeyError::InvalidSpkiPublicKey => "TypeError",
×
1483
      AsymmetricPublicKeyError::UnsupportedKeyType(_) => "TypeError",
×
1484
      AsymmetricPublicKeyError::UnsupportedKeyFormat(_) => "TypeError",
×
1485
      AsymmetricPublicKeyError::Spki(_) => "Error",
×
1486
      AsymmetricPublicKeyError::Pkcs1(_) => "Error",
×
1487
      AsymmetricPublicKeyError::RsaPssParamsParse(_) => "TypeError",
×
1488
      AsymmetricPublicKeyError::MalformedDssPublicKey => "TypeError",
×
1489
      AsymmetricPublicKeyError::MalformedOrMissingNamedCurveInEcParameters => {
1490
        "TypeError"
×
1491
      }
1492
      AsymmetricPublicKeyError::MalformedOrMissingPublicKeyInEcSpki => {
1493
        "TypeError"
×
1494
      }
1495
      AsymmetricPublicKeyError::Ec(_) => "Error",
×
1496
      AsymmetricPublicKeyError::UnsupportedEcNamedCurve => "TypeError",
×
1497
      AsymmetricPublicKeyError::MalformedOrMissingPublicKeyInX25519Spki => {
1498
        "TypeError"
×
1499
      }
1500
      AsymmetricPublicKeyError::X25519PublicKeyIsTooShort => "TypeError",
×
1501
      AsymmetricPublicKeyError::InvalidEd25519PublicKey => "TypeError",
×
1502
      AsymmetricPublicKeyError::MissingDhParameters => "TypeError",
×
1503
      AsymmetricPublicKeyError::MalformedDhParameters => "TypeError",
×
1504
      AsymmetricPublicKeyError::MalformedOrMissingPublicKeyInDhSpki => {
1505
        "TypeError"
×
1506
      }
1507
      AsymmetricPublicKeyError::UnsupportedPrivateKeyOid => "TypeError",
×
1508
    }
1509
  }
×
1510

1511
  pub fn get_private_encrypt_decrypt_error(
×
1512
    e: &PrivateEncryptDecryptError,
×
1513
  ) -> &'static str {
×
1514
    match e {
×
1515
      PrivateEncryptDecryptError::Pkcs8(_) => "Error",
×
1516
      PrivateEncryptDecryptError::Spki(_) => "Error",
×
1517
      PrivateEncryptDecryptError::Utf8(_) => "Error",
×
1518
      PrivateEncryptDecryptError::Rsa(_) => "Error",
×
1519
      PrivateEncryptDecryptError::UnknownPadding => "TypeError",
×
1520
    }
1521
  }
×
1522

1523
  pub fn get_ecdh_encode_pub_key_error(e: &EcdhEncodePubKey) -> &'static str {
×
1524
    match e {
×
1525
      EcdhEncodePubKey::InvalidPublicKey => "TypeError",
×
1526
      EcdhEncodePubKey::UnsupportedCurve => "TypeError",
×
1527
      EcdhEncodePubKey::Sec1(_) => "Error",
×
1528
    }
1529
  }
×
1530

1531
  pub fn get_diffie_hellman_error(_: &DiffieHellmanError) -> &'static str {
×
1532
    "TypeError"
×
1533
  }
×
1534

1535
  pub fn get_sign_ed25519_error(_: &SignEd25519Error) -> &'static str {
×
1536
    "TypeError"
×
1537
  }
×
1538

1539
  pub fn get_verify_ed25519_error(_: &VerifyEd25519Error) -> &'static str {
×
1540
    "TypeError"
×
1541
  }
×
1542
}
1543

1544
// fn get_os_error(error: &OsError) -> &'static str {
1545
//   match error {
1546
//     OsError::Permission(e) => get_permission_check_error_class(e),
1547
//     OsError::InvalidUtf8(_) => "InvalidData",
1548
//     OsError::EnvEmptyKey => "TypeError",
1549
//     OsError::EnvInvalidKey(_) => "TypeError",
1550
//     OsError::EnvInvalidValue(_) => "TypeError",
1551
//     OsError::Io(e) => get_io_error_class(e),
1552
//     OsError::Var(e) => get_env_var_error_class(e),
1553
//   }
1554
// }
1555

1556
// fn get_sync_fetch_error(error: &SyncFetchError) -> &'static str {
1557
//   match error {
1558
//     SyncFetchError::BlobUrlsNotSupportedInContext => "TypeError",
1559
//     SyncFetchError::Io(e) => get_io_error_class(e),
1560
//     SyncFetchError::InvalidScriptUrl => "TypeError",
1561
//     SyncFetchError::InvalidStatusCode(_) => "TypeError",
1562
//     SyncFetchError::ClassicScriptSchemeUnsupportedInWorkers(_) => "TypeError",
1563
//     SyncFetchError::InvalidUri(_) => "Error",
1564
//     SyncFetchError::InvalidMimeType(_) => "DOMExceptionNetworkError",
1565
//     SyncFetchError::MissingMimeType => "DOMExceptionNetworkError",
1566
//     SyncFetchError::Fetch(e) => get_fetch_error(e),
1567
//     SyncFetchError::Join(_) => "Error",
1568
//     SyncFetchError::Other(e) => get_error_class_name(e).unwrap_or("Error"),
1569
//   }
1570
// }
1571

1572
pub fn get_error_class_name(e: &AnyError) -> Option<&'static str> {
446✔
1573
  deno_core::error::get_custom_error_class(e)
446✔
1574
    .or_else(|| {
446✔
1575
      e.downcast_ref::<ChildPermissionError>()
33✔
1576
        .map(get_child_permission_error)
33✔
1577
    })
446✔
1578
    .or_else(|| {
446✔
1579
      e.downcast_ref::<PermissionCheckError>()
33✔
1580
        .map(get_permission_check_error_class)
33✔
1581
    })
446✔
1582
    .or_else(|| {
446✔
1583
      e.downcast_ref::<PermissionError>()
33✔
1584
        .map(get_permission_error_class)
33✔
1585
    })
446✔
1586
    .or_else(|| e.downcast_ref::<FsError>().map(get_fs_error))
446✔
1587
    .or_else(|| {
446✔
1588
      e.downcast_ref::<node::BlocklistError>()
33✔
1589
        .map(node::get_blocklist_error)
33✔
1590
    })
446✔
1591
    .or_else(|| e.downcast_ref::<node::FsError>().map(node::get_fs_error))
446✔
1592
    .or_else(|| {
446✔
1593
      e.downcast_ref::<node::IdnaError>()
33✔
1594
        .map(node::get_idna_error)
33✔
1595
    })
446✔
1596
    .or_else(|| {
446✔
1597
      e.downcast_ref::<node::IpcJsonStreamError>()
33✔
1598
        .map(node::get_ipc_json_stream_error)
33✔
1599
    })
446✔
1600
    .or_else(|| e.downcast_ref::<node::IpcError>().map(node::get_ipc_error))
446✔
1601
    .or_else(|| {
446✔
1602
      e.downcast_ref::<node::WorkerThreadsFilenameError>()
33✔
1603
        .map(node::get_worker_threads_filename_error)
33✔
1604
    })
446✔
1605
    .or_else(|| {
446✔
1606
      e.downcast_ref::<node::RequireError>()
33✔
1607
        .map(node::get_require_error)
33✔
1608
    })
446✔
1609
    .or_else(|| {
446✔
1610
      e.downcast_ref::<node::Http2Error>()
33✔
1611
        .map(node::get_http2_error)
33✔
1612
    })
446✔
1613
    .or_else(|| e.downcast_ref::<node::OsError>().map(node::get_os_error))
446✔
1614
    .or_else(|| {
446✔
1615
      e.downcast_ref::<node::BrotliError>()
33✔
1616
        .map(node::get_brotli_error)
33✔
1617
    })
446✔
1618
    .or_else(|| {
446✔
1619
      e.downcast_ref::<node::ModeError>()
33✔
1620
        .map(node::get_mode_error)
33✔
1621
    })
446✔
1622
    .or_else(|| {
446✔
1623
      e.downcast_ref::<node::ZlibError>()
33✔
1624
        .map(node::get_zlib_error)
33✔
1625
    })
446✔
1626
    .or_else(|| {
446✔
1627
      e.downcast_ref::<node::CipherError>()
33✔
1628
        .map(node::get_crypto_cipher_error)
33✔
1629
    })
446✔
1630
    .or_else(|| {
446✔
1631
      e.downcast_ref::<node::CipherContextError>()
33✔
1632
        .map(node::get_crypto_cipher_context_error)
33✔
1633
    })
446✔
1634
    .or_else(|| {
446✔
1635
      e.downcast_ref::<node::DecipherError>()
33✔
1636
        .map(node::get_crypto_decipher_error)
33✔
1637
    })
446✔
1638
    .or_else(|| {
446✔
1639
      e.downcast_ref::<node::DecipherContextError>()
33✔
1640
        .map(node::get_crypto_decipher_context_error)
33✔
1641
    })
446✔
1642
    .or_else(|| {
446✔
1643
      e.downcast_ref::<node::X509Error>()
33✔
1644
        .map(node::get_x509_error)
33✔
1645
    })
446✔
1646
    .or_else(|| {
446✔
1647
      e.downcast_ref::<node::KeyObjectHandlePrehashedSignAndVerifyError>()
33✔
1648
        .map(node::get_crypto_key_object_handle_prehashed_sign_and_verify_error)
33✔
1649
    })
446✔
1650
    .or_else(|| {
446✔
1651
      e.downcast_ref::<node::HashError>()
33✔
1652
        .map(node::get_crypto_hash_error)
33✔
1653
    })
446✔
1654
    .or_else(|| {
446✔
1655
      e.downcast_ref::<node::AsymmetricPublicKeyJwkError>()
33✔
1656
        .map(node::get_asymmetric_public_key_jwk_error)
33✔
1657
    })
446✔
1658
    .or_else(|| {
446✔
1659
      e.downcast_ref::<node::GenerateRsaPssError>()
33✔
1660
        .map(node::get_generate_rsa_pss_error)
33✔
1661
    })
446✔
1662
    .or_else(|| {
446✔
1663
      e.downcast_ref::<node::AsymmetricPrivateKeyDerError>()
33✔
1664
        .map(node::get_asymmetric_private_key_der_error)
33✔
1665
    })
446✔
1666
    .or_else(|| {
446✔
1667
      e.downcast_ref::<node::AsymmetricPublicKeyDerError>()
33✔
1668
        .map(node::get_asymmetric_public_key_der_error)
33✔
1669
    })
446✔
1670
    .or_else(|| {
446✔
1671
      e.downcast_ref::<node::ExportPublicKeyPemError>()
33✔
1672
        .map(node::get_export_public_key_pem_error)
33✔
1673
    })
446✔
1674
    .or_else(|| {
446✔
1675
      e.downcast_ref::<node::ExportPrivateKeyPemError>()
33✔
1676
        .map(node::get_export_private_key_pem_error)
33✔
1677
    })
446✔
1678
    .or_else(|| {
446✔
1679
      e.downcast_ref::<node::RsaJwkError>()
33✔
1680
        .map(node::get_rsa_jwk_error)
33✔
1681
    })
446✔
1682
    .or_else(|| {
446✔
1683
      e.downcast_ref::<node::EcJwkError>()
33✔
1684
        .map(node::get_ec_jwk_error)
33✔
1685
    })
446✔
1686
    .or_else(|| {
446✔
1687
      e.downcast_ref::<node::EdRawError>()
33✔
1688
        .map(node::get_ed_raw_error)
33✔
1689
    })
446✔
1690
    .or_else(|| {
446✔
1691
      e.downcast_ref::<node::Pbkdf2Error>()
33✔
1692
        .map(node::get_pbkdf2_error)
33✔
1693
    })
446✔
1694
    .or_else(|| {
446✔
1695
      e.downcast_ref::<node::ScryptAsyncError>()
33✔
1696
        .map(node::get_scrypt_async_error)
33✔
1697
    })
446✔
1698
    .or_else(|| {
446✔
1699
      e.downcast_ref::<node::HkdfError>()
33✔
1700
        .map(node::get_hkdf_error_error)
33✔
1701
    })
446✔
1702
    .or_else(|| {
446✔
1703
      e.downcast_ref::<node::RsaPssParamsParseError>()
33✔
1704
        .map(node::get_rsa_pss_params_parse_error)
33✔
1705
    })
446✔
1706
    .or_else(|| {
446✔
1707
      e.downcast_ref::<node::AsymmetricPrivateKeyError>()
33✔
1708
        .map(node::get_asymmetric_private_key_error)
33✔
1709
    })
446✔
1710
    .or_else(|| {
446✔
1711
      e.downcast_ref::<node::AsymmetricPublicKeyError>()
33✔
1712
        .map(node::get_asymmetric_public_key_error)
33✔
1713
    })
446✔
1714
    .or_else(|| {
446✔
1715
      e.downcast_ref::<node::PrivateEncryptDecryptError>()
33✔
1716
        .map(node::get_private_encrypt_decrypt_error)
33✔
1717
    })
446✔
1718
    .or_else(|| {
446✔
1719
      e.downcast_ref::<node::EcdhEncodePubKey>()
33✔
1720
        .map(node::get_ecdh_encode_pub_key_error)
33✔
1721
    })
446✔
1722
    .or_else(|| {
446✔
1723
      e.downcast_ref::<node::DiffieHellmanError>()
33✔
1724
        .map(node::get_diffie_hellman_error)
33✔
1725
    })
446✔
1726
    .or_else(|| {
446✔
1727
      e.downcast_ref::<node::SignEd25519Error>()
33✔
1728
        .map(node::get_sign_ed25519_error)
33✔
1729
    })
446✔
1730
    .or_else(|| {
446✔
1731
      e.downcast_ref::<node::VerifyEd25519Error>()
33✔
1732
        .map(node::get_verify_ed25519_error)
33✔
1733
    })
446✔
1734
    // .or_else(|| e.downcast_ref::<NApiError>().map(get_napi_error_class))
446✔
1735
    .or_else(|| e.downcast_ref::<WebError>().map(get_web_error_class))
446✔
1736
    // .or_else(|| {
446✔
1737
    //   e.downcast_ref::<CreateWorkerError>()
446✔
1738
    //     .map(get_create_worker_error)
446✔
1739
    // })
446✔
1740
    // .or_else(|| e.downcast_ref::<TtyError>().map(get_tty_error))
446✔
1741
    // .or_else(|| e.downcast_ref::<ReadlineError>().map(get_readline_error))
446✔
1742
    // .or_else(|| e.downcast_ref::<SignalError>().map(get_signal_error))
446✔
1743
    // .or_else(|| e.downcast_ref::<FsEventsError>().map(get_fs_events_error))
446✔
1744
    // .or_else(|| e.downcast_ref::<HttpStartError>().map(get_http_start_error))
446✔
1745
    // .or_else(|| e.downcast_ref::<ProcessError>().map(get_process_error))
446✔
1746
    // .or_else(|| e.downcast_ref::<OsError>().map(get_os_error))
446✔
1747
    // .or_else(|| e.downcast_ref::<SyncFetchError>().map(get_sync_fetch_error))
446✔
1748
    .or_else(|| {
446✔
1749
      e.downcast_ref::<CompressionError>()
33✔
1750
        .map(get_web_compression_error_class)
33✔
1751
    })
446✔
1752
    .or_else(|| {
446✔
1753
      e.downcast_ref::<MessagePortError>()
33✔
1754
        .map(get_web_message_port_error_class)
33✔
1755
    })
446✔
1756
    .or_else(|| {
446✔
1757
      e.downcast_ref::<StreamResourceError>()
33✔
1758
        .map(get_web_stream_resource_error_class)
33✔
1759
    })
446✔
1760
    .or_else(|| e.downcast_ref::<BlobError>().map(get_web_blob_error_class))
446✔
1761
    // .or_else(|| e.downcast_ref::<IRError>().map(|_| "TypeError"))
446✔
1762
    // .or_else(|| e.downcast_ref::<ReprError>().map(get_ffi_repr_error_class))
446✔
1763
    .or_else(|| e.downcast_ref::<HttpError>().map(get_http_error))
446✔
1764
    .or_else(|| e.downcast_ref::<HttpNextError>().map(get_http_next_error))
446✔
1765
    .or_else(|| {
446✔
1766
      e.downcast_ref::<WebSocketUpgradeError>()
10✔
1767
        .map(get_websocket_upgrade_error)
10✔
1768
    })
446✔
1769
    .or_else(|| e.downcast_ref::<FsOpsError>().map(get_fs_ops_error))
446✔
1770
    // .or_else(|| {
446✔
1771
    //   e.downcast_ref::<DlfcnError>()
446✔
1772
    //     .map(get_ffi_dlfcn_error_class)
446✔
1773
    // })
446✔
1774
    // .or_else(|| {
446✔
1775
    //   e.downcast_ref::<StaticError>()
446✔
1776
    //     .map(get_ffi_static_error_class)
446✔
1777
    // })
446✔
1778
    // .or_else(|| {
446✔
1779
    //   e.downcast_ref::<CallbackError>()
446✔
1780
    //     .map(get_ffi_callback_error_class)
446✔
1781
    // })
446✔
1782
    // .or_else(|| e.downcast_ref::<CallError>().map(get_ffi_call_error_class))
446✔
1783
    .or_else(|| e.downcast_ref::<TlsError>().map(get_tls_error_class))
446✔
1784
    // .or_else(|| e.downcast_ref::<CronError>().map(get_cron_error_class))
446✔
1785
    // .or_else(|| e.downcast_ref::<CanvasError>().map(get_canvas_error))
446✔
1786
    // .or_else(|| e.downcast_ref::<CacheError>().map(get_cache_error))
446✔
1787
    .or_else(|| e.downcast_ref::<WebsocketError>().map(get_websocket_error))
446✔
1788
    .or_else(|| {
446✔
1789
      e.downcast_ref::<HandshakeError>()
9✔
1790
        .map(get_websocket_handshake_error)
9✔
1791
    })
446✔
1792
    // .or_else(|| e.downcast_ref::<KvError>().map(get_kv_error))
446✔
1793
    .or_else(|| e.downcast_ref::<FetchError>().map(get_fetch_error))
446✔
1794
    .or_else(|| {
446✔
1795
      e.downcast_ref::<HttpClientCreateError>()
7✔
1796
        .map(get_http_client_create_error)
7✔
1797
    })
446✔
1798
    .or_else(|| e.downcast_ref::<NetError>().map(get_net_error))
446✔
1799
    .or_else(|| {
446✔
1800
      e.downcast_ref::<deno_net::io::MapError>()
6✔
1801
        .map(get_net_map_error)
6✔
1802
    })
446✔
1803
    // .or_else(|| {
446✔
1804
    //   e.downcast_ref::<BroadcastChannelError>()
446✔
1805
    //     .map(get_broadcast_channel_error)
446✔
1806
    // })
446✔
1807
    // .or_else(|| {
446✔
1808
    //   e.downcast_ref::<deno_webgpu::InitError>()
446✔
1809
    //     .map(get_webgpu_error_class)
446✔
1810
    // })
446✔
1811
    // .or_else(|| {
446✔
1812
    //   e.downcast_ref::<deno_webgpu::buffer::BufferError>()
446✔
1813
    //     .map(get_webgpu_buffer_error_class)
446✔
1814
    // })
446✔
1815
    // .or_else(|| {
446✔
1816
    //   e.downcast_ref::<deno_webgpu::bundle::BundleError>()
446✔
1817
    //     .map(get_webgpu_bundle_error_class)
446✔
1818
    // })
446✔
1819
    // .or_else(|| {
446✔
1820
    //   e.downcast_ref::<deno_webgpu::byow::ByowError>()
446✔
1821
    //     .map(get_webgpu_byow_error_class)
446✔
1822
    // })
446✔
1823
    // .or_else(|| {
446✔
1824
    //   e.downcast_ref::<deno_webgpu::render_pass::RenderPassError>()
446✔
1825
    //     .map(get_webgpu_render_pass_error_class)
446✔
1826
    // })
446✔
1827
    // .or_else(|| {
446✔
1828
    //   e.downcast_ref::<deno_webgpu::surface::SurfaceError>()
446✔
1829
    //     .map(get_webgpu_surface_error_class)
446✔
1830
    // })
446✔
1831
    .or_else(|| {
446✔
1832
      e.downcast_ref::<DecryptError>()
6✔
1833
        .map(get_crypto_decrypt_error_class)
6✔
1834
    })
446✔
1835
    .or_else(|| {
446✔
1836
      e.downcast_ref::<EncryptError>()
6✔
1837
        .map(get_crypto_encrypt_error_class)
6✔
1838
    })
446✔
1839
    .or_else(|| {
446✔
1840
      e.downcast_ref::<deno_crypto::SharedError>()
6✔
1841
        .map(get_crypto_shared_error_class)
6✔
1842
    })
446✔
1843
    .or_else(|| {
446✔
1844
      e.downcast_ref::<deno_crypto::Ed25519Error>()
6✔
1845
        .map(get_crypto_ed25519_error_class)
6✔
1846
    })
446✔
1847
    .or_else(|| {
446✔
1848
      e.downcast_ref::<ExportKeyError>()
6✔
1849
        .map(get_crypto_export_key_error_class)
6✔
1850
    })
446✔
1851
    .or_else(|| {
446✔
1852
      e.downcast_ref::<GenerateKeyError>()
6✔
1853
        .map(get_crypto_generate_key_error_class)
6✔
1854
    })
446✔
1855
    .or_else(|| {
446✔
1856
      e.downcast_ref::<ImportKeyError>()
6✔
1857
        .map(get_crypto_import_key_error_class)
6✔
1858
    })
446✔
1859
    .or_else(|| {
446✔
1860
      e.downcast_ref::<deno_crypto::X448Error>()
6✔
1861
        .map(get_crypto_x448_error_class)
6✔
1862
    })
446✔
1863
    .or_else(|| {
446✔
1864
      e.downcast_ref::<deno_crypto::X25519Error>()
6✔
1865
        .map(get_crypto_x25519_error_class)
6✔
1866
    })
446✔
1867
    .or_else(|| {
446✔
1868
      e.downcast_ref::<deno_crypto::Error>()
6✔
1869
        .map(get_crypto_error_class)
6✔
1870
    })
446✔
1871
    .or_else(|| {
446✔
1872
      e.downcast_ref::<WebStorageError>()
6✔
1873
        .map(get_webstorage_class_name)
6✔
1874
    })
446✔
1875
    .or_else(|| {
446✔
1876
      e.downcast_ref::<deno_url::UrlPatternError>()
6✔
1877
        .map(|_| "TypeError")
6✔
1878
    })
446✔
1879
    // .or_else(|| {
446✔
1880
    //   e.downcast_ref::<dlopen2::Error>()
446✔
1881
    //     .map(get_dlopen_error_class)
446✔
1882
    // })
446✔
1883
    .or_else(|| e.downcast_ref::<hyper::Error>().map(get_hyper_error_class))
446✔
1884
    .or_else(|| {
446✔
1885
      e.downcast_ref::<hyper_util::client::legacy::Error>()
6✔
1886
        .map(get_hyper_util_error_class)
6✔
1887
    })
446✔
1888
    .or_else(|| {
446✔
1889
      e.downcast_ref::<hyper_v014::Error>()
6✔
1890
        .map(get_hyper_v014_error_class)
6✔
1891
    })
446✔
1892
    .or_else(|| {
446✔
1893
      e.downcast_ref::<Arc<hyper_v014::Error>>()
6✔
1894
        .map(|e| get_hyper_v014_error_class(e))
6✔
1895
    })
446✔
1896
    .or_else(|| {
446✔
1897
      e.downcast_ref::<deno_core::Canceled>().map(|e| {
6✔
1898
        let io_err: io::Error = e.to_owned().into();
2✔
1899
        get_io_error_class(&io_err)
2✔
1900
      })
6✔
1901
    })
446✔
1902
    .or_else(|| {
446✔
1903
      e.downcast_ref::<env::VarError>()
4✔
1904
        .map(get_env_var_error_class)
4✔
1905
    })
446✔
1906
    .or_else(|| e.downcast_ref::<io::Error>().map(get_io_error_class))
446✔
1907
    .or_else(|| {
446✔
1908
      e.downcast_ref::<ModuleResolutionError>()
4✔
1909
        .map(get_module_resolution_error_class)
4✔
1910
    })
446✔
1911
    .or_else(|| {
446✔
1912
      e.downcast_ref::<notify::Error>()
4✔
1913
        .map(get_notify_error_class)
4✔
1914
    })
446✔
1915
    .or_else(|| e.downcast_ref::<regex::Error>().map(get_regex_error_class))
446✔
1916
    .or_else(|| {
446✔
1917
      e.downcast_ref::<serde_json::error::Error>()
4✔
1918
        .map(get_serde_json_error_class)
4✔
1919
    })
446✔
1920
    .or_else(|| {
446✔
1921
      e.downcast_ref::<url::ParseError>()
4✔
1922
        .map(get_url_parse_error_class)
4✔
1923
    })
446✔
1924
    // .or_else(|| {
446✔
1925
    //   e.downcast_ref::<deno_kv::sqlite::SqliteBackendError>()
446✔
1926
    //     .map(|_| "TypeError")
446✔
1927
    // })
446✔
1928
    .or_else(|| {
446✔
1929
      #[cfg(unix)]
4✔
1930
      let maybe_get_nix_error_class =
4✔
1931
        || e.downcast_ref::<nix::Error>().map(get_nix_error_class);
4✔
1932
      #[cfg(not(unix))]
1933
      let maybe_get_nix_error_class = || Option::<&'static str>::None;
1934
      (maybe_get_nix_error_class)()
4✔
1935
    })
446✔
1936
}
446✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc