/**
 * @license
 * Copyright 2022-2026 Greg Lauckhart <greg@lauckhart.com>
 * SPDX-License-Identifier: Apache-2.0
 */
function notCode(code, cause) {
  const causeCode = cause?.code;
  if (typeof code === "string") {
    return code !== causeCode;
  }
  return !code.includes(causeCode);
}
async function ignoreError(code, fn) {
  try {
    return await fn();
  } catch (e) {
    if (notCode(code, e)) {
      throw e;
    }
  }
}
function ignoreErrorSync(code, fn) {
  try {
    return fn();
  } catch (e) {
    if (notCode(code, e)) {
      throw e;
    }
  }
}
export {
  ignoreError,
  ignoreErrorSync
};
//# sourceMappingURL=errors.js.map
