Skip to content

site: a real example for every Error method - #2476

Merged
BaseMax merged 2 commits into
mainfrom
site/error-examples
Oct 28, 2026
Merged

BaseMax merged 2 commits into
mainfrom
site/error-examples

Conversation

@BaseMax

@BaseMax BaseMax commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #2475, which only pointed the Error methods at one shared example.

  • one example per method in en and fa: New, At, is, wrap, with_code, with_path, with_position, kind_name, to_str
  • a dedicated ErrorKind example (retry or give up by kind)
  • salam doc listed static functions under a hidden name (__Error__New), so New and At were missing from the page; they are now members of Error, with docs

Every core example passes check-example.sh and both sites build.

Summary by CodeRabbit

  • Documentation
    • Added examples demonstrating error creation, validation, classification, formatting, and handling contextual details such as codes, paths, and positions.
    • Expanded reference documentation for creating errors with messages and recording byte offsets.
    • Generated documentation now lists static functions under their matching structs when the function name identifies an existing struct.

salam doc hid them under the lowered name __Error__New, so Error.New and Error.At were missing from the std pages.
Each method has its own example in en and fa instead of sharing core-Error.
@BaseMax
BaseMax requested a review from a team as a code owner October 28, 2026 20:24
@vercel

vercel Bot commented Oct 28, 2026

Copy link
Copy Markdown

Deployment failed for project salam with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/salamlang?upgradeToPro=build-rate-limit

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

The documentation walker now associates encoded static functions with matching structs. The pull request also adds English and Persian core Error examples and updates the related standard-library reference entries and example mappings.

Changes: Core Error documentation

Layer / File(s) Summary
Static function documentation and references
compiler/docgen/docgen_walk.salam, website/content/en/std/01-core.txt, website/content/fa/std/01-core.txt
The walker can document a static function as a member of a matching top-level struct after removing its encoded owner prefix. The core reference adds Error.New and Error.At entries and removes several example mappings.
Error construction and representation examples
website/content/{en,fa}/std-examples/core/core-Error.{At,New,kind_name,to_str}.salam
Examples demonstrate Error.At and Error.New, error kind names, and string representations, including wrapped errors.
Error matching and metadata examples
website/content/{en,fa}/std-examples/core/core-Error.{is,with_code,with_path,with_position,wrap}.salam, website/content/{en,fa}/std-examples/core/core-ErrorKind.salam
Examples demonstrate error matching and retryability checks, plus error codes, paths, positions, and wrapping context.

Priority: Not assessed

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Suggested reviewers: bdadmehr0, erfangnu

Merge Risk: Low · up to d9d39

Generated documentation can misplace static methods when files contain same-named structs. The change is otherwise mergeable with that limitation understood.

Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@BaseMax
BaseMax merged commit bb0f692 into main Oct 28, 2026
40 of 51 checks passed
@BaseMax
BaseMax deleted the site/error-examples branch October 28, 2026 20:28
@github-actions

Copy link
Copy Markdown
Contributor

Super-linter summary

Language Validation result
CHECKOV Pass ✅
EDITORCONFIG Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
PRE_COMMIT Pass ✅
SPELL_CODESPELL Pass ✅
TRIVY Fail ❌

Super-linter detected linting errors

For more information, see the GitHub Actions workflow run

Powered by Super-linter
Super-linter revision: 2da136927bd4a73596db63044b504547c62cb854
Super-linter version: 9.0.0

TRIVY

Report Summary

┌──────────────────────────────────────────────────────┬────────────┬─────────────────┬───────────────────┬─────────┐
│                        Target                        │    Type    │ Vulnerabilities │ Misconfigurations │ Secrets │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ agent/src-tauri/Cargo.lock                           │   cargo    │        0        │         -         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ ai/frontend/bun.lock                                 │    bun     │        0        │         -         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ bun.lock                                             │    bun     │        0        │         -         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ runner/container/server/go.mod                       │   gomod    │        0        │         -         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ tests/en/apps/httpbench/bench/echo/go.mod            │   gomod    │        2        │         -         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ tests/en/apps/httpbench/bench/fiber/go.mod           │   gomod    │        0        │         -         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ tests/en/apps/httpbench/bench/gin/go.mod             │   gomod    │        0        │         -         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ tests/en/apps/httpbench/bench/go/go.mod              │   gomod    │        0        │         -         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ tests/en/apps/httpbench/bench/node/package-lock.json │    npm     │        0        │         -         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ uv.lock                                              │     uv     │        0        │         -         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ .github/docker/armhf-builder/Dockerfile              │ dockerfile │        -        │         0         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ ai/backend/Dockerfile                                │ dockerfile │        -        │         0         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ benchmark/docker/Dockerfile                          │ dockerfile │        -        │         0         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ books/docker/Dockerfile                              │ dockerfile │        -        │         0         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ docker/Dockerfile                                    │ dockerfile │        -        │         0         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ runner/container/Dockerfile                          │ dockerfile │        -        │         0         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ sandbox/Dockerfile                                   │ dockerfile │        -        │         0         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ sandbox/image/Dockerfile                             │ dockerfile │        -        │         0         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ tools/mcp/Dockerfile                                 │ dockerfile │        -        │         0         │    -    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ packages/ssh/selftest_privatekey.salam               │    text    │        -        │         -         │    0    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ website/content/en/learn/36-css-responsive.txt       │    text    │        -        │         -         │    0    │
├──────────────────────────────────────────────────────┼────────────┼─────────────────┼───────────────────┼─────────┤
│ website/content/fa/learn/36-css-responsive.txt       │    text    │        -        │         -         │    0    │
└──────────────────────────────────────────────────────┴────────────┴─────────────────┴───────────────────┴─────────┘
Legend:
- '-': Not scanned
- '0': Clean (no security findings detected)


For OSS Maintainers: VEX Notice
--------------------------------
If you're an OSS maintainer and Trivy has detected vulnerabilities in your project that you believe are not actually exploitable, consider issuing a VEX (Vulnerability Exploitability eXchange) statement.
VEX allows you to communicate the actual status of vulnerabilities in your project, improving security transparency and reducing false positives for your users.
Learn more and start using VEX: https://trivy.dev/docs/v0.74/guide/supply-chain/vex/repo#publishing-vex-documents

To disable this notice, set the TRIVY_DISABLE_VEX_NOTICE environment variable.


tests/en/apps/httpbench/bench/echo/go.mod (gomod)
=================================================
Total: 2 (UNKNOWN: 0, LOW: 0, MEDIUM: 2, HIGH: 0, CRITICAL: 0)

┌─────────────────────────────┬─────────────────┬──────────┬──────────┬───────────────────┬───────────────┬─────────────────────────────────────────────────────────────┐
│           Library           │  Vulnerability  │ Severity │  Status  │ Installed Version │ Fixed Version │                            Title                            │
├─────────────────────────────┼─────────────────┼──────────┼──────────┼───────────────────┼───────────────┼─────────────────────────────────────────────────────────────┤
│ github.com/labstack/echo/v4 │ CVE-2026-118651 │ MEDIUM   │ affected │ v4.16.2           │               │ Echo: Reverse Proxy Forwards Attacker-Supplied X-Real-IP to │
│                             │                 │          │          │                   │               │ Upstream by Default                                         │
│                             │                 │          │          │                   │               │ https://avd.aquasec.com/nvd/cve-2026-118651                 │
│                             ├─────────────────┤          │          │                   ├───────────────┼─────────────────────────────────────────────────────────────┤
│                             │ CVE-2026-118653 │          │          │                   │               │ Echo has Rate Limiter Bypass via Spoofed X-Forwarded-For    │
│                             │                 │          │          │                   │               │ Header in Default Configuration...                          │
│                             │                 │          │          │                   │               │ https://avd.aquasec.com/nvd/cve-2026-118653                 │
└─────────────────────────────┴─────────────────┴──────────┴──────────┴───────────────────┴───────────────┴─────────────────────────────────────────────────────────────┘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant