@webpieces/rules-config 0.4.943 → 0.4.944
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/rules-config",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.944",
|
|
4
4
|
"description": "Shared webpieces.config.json loader. Single source of truth for validation rule configuration consumed by @webpieces/ai-hook-rules, @webpieces/code-rules, and @webpieces/nx-webpieces-rules.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"inversify": "7.10.4",
|
|
20
20
|
"reflect-metadata": "0.2.2",
|
|
21
21
|
"minimatch": "10.0.1",
|
|
22
|
-
"@webpieces/tooling-common": "0.4.
|
|
23
|
-
"@webpieces/repo-workflow-core": "0.4.
|
|
24
|
-
"@webpieces/rules-sdk": "0.4.
|
|
22
|
+
"@webpieces/tooling-common": "0.4.944",
|
|
23
|
+
"@webpieces/repo-workflow-core": "0.4.944",
|
|
24
|
+
"@webpieces/rules-sdk": "0.4.944"
|
|
25
25
|
},
|
|
26
26
|
"author": "Dean Hiller",
|
|
27
27
|
"license": "Apache-2.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@webpieces/tooling-testkit": "0.4.
|
|
37
|
+
"@webpieces/tooling-testkit": "0.4.944"
|
|
38
38
|
},
|
|
39
39
|
"types": "./src/index.d.ts",
|
|
40
40
|
"bin": {
|
|
@@ -739,6 +739,53 @@ const config = JSON.parse(raw);
|
|
|
739
739
|
The `cause` field is available on the original error object and will appear in stack traces
|
|
740
740
|
and in `/debugLocal/{traceId}` responses.
|
|
741
741
|
|
|
742
|
+
## Rule: catch-must-propagate
|
|
743
|
+
|
|
744
|
+
`throw-cause-required` only fires on a THROW inside a catch. A catch that copies `error.message` into a
|
|
745
|
+
field, a variable or a return value, and lets the error go, throws nothing — so the cause disappears and
|
|
746
|
+
a later, generic error says nothing of why. `catch-must-propagate` judges the catch itself: the caught
|
|
747
|
+
error must leave it WHOLE.
|
|
748
|
+
|
|
749
|
+
### BAD (triggers violation)
|
|
750
|
+
```typescript
|
|
751
|
+
} catch (err: unknown) {
|
|
752
|
+
const error = toError(err);
|
|
753
|
+
this.diagnostic = error.message; // ← only the text survives
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
} catch { // ← no binding: the error is dropped
|
|
757
|
+
return undefined;
|
|
758
|
+
}
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
### GOOD — any one of these, with the error whole
|
|
762
|
+
```typescript
|
|
763
|
+
} catch (err: unknown) {
|
|
764
|
+
const error = toError(err);
|
|
765
|
+
throw new Error('Cannot decode the saved script', { cause: error }); // thrown as a cause
|
|
766
|
+
}
|
|
767
|
+
} catch (err: unknown) {
|
|
768
|
+
log.warn('decode failed', toError(err)); // a configured forwarder (catch-must-propagate.forwards)
|
|
769
|
+
}
|
|
770
|
+
} catch (err: unknown) {
|
|
771
|
+
this.lastError = toError(err); // stored whole on a member for a later throw
|
|
772
|
+
}
|
|
773
|
+
} catch (err: unknown) {
|
|
774
|
+
return toError(err); // returned whole to a caller that throws it
|
|
775
|
+
}
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
Only `err.message`, `String(err)`, `JSON.stringify(err)`, a template or `+` does NOT count. A helper
|
|
779
|
+
the error is passed to (`report(err)`) counts only once its name is listed in the rule's `forwards`.
|
|
780
|
+
|
|
781
|
+
If dropping the error is genuinely correct (an EXPECTED condition, not a defect), say why, per site, on
|
|
782
|
+
the catch's line or the line above it — a reason of at least 20 characters is required:
|
|
783
|
+
|
|
784
|
+
```typescript
|
|
785
|
+
// webpieces-disable catch-must-propagate -- a missing file is the expected first-run state
|
|
786
|
+
} catch {
|
|
787
|
+
```
|
|
788
|
+
|
|
742
789
|
## Summary
|
|
743
790
|
|
|
744
791
|
**The webpieces philosophy**: Errors should bubble to the global handler where they are logged with traceId and stored for debugging. Local try-catch blocks break this architecture and create blind spots in production.
|