windsor-bot 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,16 +9,25 @@ export class PrinterUnavailableError extends Error {
9
9
  }
10
10
  }
11
11
  function isUnavailableError(error) {
12
- if (!(error instanceof Error))
13
- return false;
14
- const code = 'code' in error ? error.code : undefined;
15
- const message = error.message.toLowerCase();
16
- return code === 'ENOENT' ||
17
- code === 'ENODEV' ||
18
- code === 'ENXIO' ||
19
- message.includes('printer or class does not exist') ||
20
- message.includes('no printer') ||
21
- message.includes('device or resource busy');
12
+ let current = error;
13
+ for (let depth = 0; depth < 4 && current; depth++) {
14
+ if (!(current instanceof Error))
15
+ return false;
16
+ const code = 'code' in current ? String(current.code) : '';
17
+ const message = `${current.name} ${current.message}`.toLowerCase();
18
+ if (code === 'ENOENT' ||
19
+ code === 'ENODEV' ||
20
+ code === 'ENXIO' ||
21
+ message.includes('enoent') ||
22
+ message.includes('no such file or directory') ||
23
+ message.includes('printer or class does not exist') ||
24
+ message.includes('no printer') ||
25
+ message.includes('device or resource busy')) {
26
+ return true;
27
+ }
28
+ current = 'cause' in current ? current.cause : undefined;
29
+ }
30
+ return false;
22
31
  }
23
32
  export async function printJob(job) {
24
33
  const cfg = getCurrentConfig();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windsor-bot",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Self-hosted Discord bot automation for household list and todo printing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",