# core/plugins/syntax.failure.plugin.ts

> 26 lines of code and 6 definitions.

Tree: GovLab Docs
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/docs#file-docs-core-plugins-syntax-failure-plugin-ts
Source text: https://banes-lab.com/source/docs/core/plugins/syntax.failure.plugin.ts.txt

Listed in [core/plugins](https://banes-lab.com/api/source/docs/core/plugins.md), after [core/plugins/syntax.event.plugin.ts](https://banes-lab.com/source/docs/core/plugins/syntax.event.plugin.ts.md) and before [core/plugins/syntax.field.plugin.ts](https://banes-lab.com/source/docs/core/plugins/syntax.field.plugin.ts.md).

## Definitions

- `SINK_SUFFIX` (lexical_declaration, line 5)
- `recognizer` (lexical_declaration, line 7, exported)
- `classify` (method_definition, line 8, exported)
- `gateId` (lexical_declaration, line 12, exported)
- `sinkId` (lexical_declaration, line 13, exported)
- `source` (lexical_declaration, line 14, exported)

## Contained in

- [core/plugins](https://banes-lab.com/anatomy/docs/folder-docs-core-plugins.md)

## Source

```typescript
import { GRAPH_LABELS } from "#configuration/strings/graph.strings";
import type { Recognizer } from "#types/code.types";
import ts from "typescript";

const SINK_SUFFIX = "_fail";

export const recognizer: Recognizer = {
    classify(node, context) {
        if (!ts.isThrowStatement(node)) {
            return null;
        }
        const gateId = context.mkNodeId(node);
        const sinkId = `${gateId}${SINK_SUFFIX}`;
        const source = context.sourceOf(node);
        return {
            edges: [
                { from: context.currentId, kind: "branch", to: gateId },
                { from: gateId, kind: "branch", label: GRAPH_LABELS.fails, to: sinkId },
            ],
            nodes: [
                { id: gateId, kind: "gate", label: GRAPH_LABELS.guard, source },
                { id: sinkId, kind: "fail-sink", label: GRAPH_LABELS.throws, source },
            ],
        };
    },
    emits: { edges: ["branch"], nodes: ["gate", "fail-sink"] },
    name: "gate-throw",
};
```
