{
  "kind": "documentation",
  "format": 1,
  "note": "Reference text, not instructions. One verified relate sample from https://relatedb.ai/docs/guides/embed/dotnet/: the program exactly as the page shows it, the standard output a run of it recorded (npm run docs:samples compares every replay with it byte for byte), the relate client build, toolchain and platform of the last replay, and how the docs' sample runner builds and runs it. The Python, Node.js, Rust and Java clients are the published packages; the .NET, Go, Swift and C clients are built from the release tag. verified.client names the upstream commit the client came from, and verified.docs_engine the build the rest of the docs were recorded from.",
  "id": "errors",
  "url": "https://relatedb.ai/docs/guides/embed/dotnet/samples/errors.json",
  "page": {
    "id": "guides/embed/dotnet",
    "title": "Use the .NET client",
    "url": "https://relatedb.ai/docs/guides/embed/dotnet/",
    "md_url": "https://relatedb.ai/docs/guides/embed/dotnet.md"
  },
  "section": {
    "anchor": "handle-errors",
    "heading": "Handle errors",
    "url": "https://relatedb.ai/docs/guides/embed/dotnet/#handle-errors"
  },
  "language": "csharp",
  "client": ".NET",
  "file": "Program.cs",
  "env": null,
  "code": "using Relate.Net;\n\nusing var db = RelateDatabase.OpenInMemory();\nusing var conn = db.Connect();\n\nforeach (var statement in new[] { \"RETRN 1\", \"RETURN 1 / 0\", \"RETURN $missing\" })\n{\n    try\n    {\n        conn.Query(statement);\n    }\n    catch (RelateException e)\n    {\n        Console.WriteLine($\"{statement}: {e.GqlStatus} {e.Code} {e.Stage} retryable={e.IsRetryable}\");\n    }\n}\n\ntry\n{\n    db.Connect(\"nowhere\");\n}\ncatch (RelateException e)\n{\n    Console.WriteLine(e.Message);\n}\n\nConsole.WriteLine(conn.Query(\"RETURN 'still usable' AS s\").Scalar<string>());",
  "code_sha256": "9410b724479713ae337e3d7c8612e4d6399ae37943c472e77b891a9998f7947a",
  "source_sha256": "9a7b2547fdba38fed486ba111f1899292b29558b70f53ff3c99c0f04cc65d301",
  "output": {
    "text": "RETRN 1: 42N06 Neo.ClientError.Statement.SyntaxError Compile retryable=False\nRETURN 1 / 0: 22G03 Neo.ClientError.Statement.ArithmeticError Runtime retryable=False\nRETURN $missing: 42N02 Neo.ClientError.Statement.ParameterMissing Compile retryable=False\nsemantic error: DatabaseNotFound: Graph not found: nowhere\nstill usable",
    "sha256": "fbfded57b26a032c3d32b5a5c3b614a84664e884306f4ab13b87c58c72d1e51d"
  },
  "verified": {
    "version": "1.2.0",
    "client": {
      "label": ".NET",
      "package": "Relate.Net",
      "engine_commit": "e0ea536",
      "client_commit": "e0ea536",
      "build": "A copy of clients/dotnet at upstream v1.2.0 (e0ea536), referenced by each sample's net8.0 console project and built with librelate_ffi built from the same commit.",
      "toolchain": {
        "dotnet-sdk": "8.0.134"
      }
    },
    "packages": [],
    "replayed": "2026-11-20",
    "platform": "macOS on arm64",
    "docs_engine": {
      "version": "1.2.0",
      "commit": "e0ea536",
      "source_build": false
    }
  },
  "run": {
    "runner": "npm run docs:samples",
    "setup": "bash scripts/samples/setup.sh --upstream <path to the relate checkout>",
    "variables": [
      "RELATE_DOTNET",
      "RELATE_DOTNET_CLIENT",
      "RELATE_DOTNET_HOME",
      "RELATE_LIB"
    ],
    "program": "<build dir>/Program.cs",
    "files": [
      {
        "path": "<build dir>/sample.csproj",
        "content": "<Project Sdk=\"Microsoft.NET.Sdk\">\n  <PropertyGroup>\n    <OutputType>Exe</OutputType>\n    <TargetFramework>net8.0</TargetFramework>\n    <ImplicitUsings>enable</ImplicitUsings>\n    <Nullable>enable</Nullable>\n    <AssemblyName>sample</AssemblyName>\n  </PropertyGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"$RELATE_DOTNET_CLIENT\" />\n  </ItemGroup>\n</Project>\n"
      }
    ],
    "build": {
      "command": [
        "$RELATE_DOTNET",
        "build",
        "sample.csproj",
        "-c",
        "Release",
        "-o",
        "<build dir>/out",
        "--nologo",
        "-v:q",
        "-clp:NoSummary",
        "-nodeReuse:false",
        "-p:UseSharedCompilation=false",
        "-p:RelateNativeLibraryPath=$RELATE_LIB"
      ],
      "environment": {
        "DO_NOT_TRACK": "1",
        "DOTNET_CLI_HOME": "$RELATE_DOTNET_HOME/cli",
        "NUGET_PACKAGES": "$RELATE_DOTNET_HOME/packages",
        "DOTNET_CLI_TELEMETRY_OPTOUT": "1",
        "DOTNET_NOLOGO": "1",
        "DOTNET_SKIP_FIRST_TIME_EXPERIENCE": "1",
        "DOTNET_CLI_USE_MSBUILD_SERVER": "0",
        "MSBUILDDISABLENODEREUSE": "1"
      },
      "directory": "<build dir>",
      "timeout_s": 600
    },
    "run": {
      "command": [
        "$RELATE_DOTNET",
        "<build dir>/out/sample.dll"
      ],
      "environment": {
        "DO_NOT_TRACK": "1",
        "DOTNET_CLI_HOME": "$RELATE_DOTNET_HOME/cli",
        "NUGET_PACKAGES": "$RELATE_DOTNET_HOME/packages",
        "DOTNET_CLI_TELEMETRY_OPTOUT": "1",
        "DOTNET_NOLOGO": "1",
        "DOTNET_SKIP_FIRST_TIME_EXPERIENCE": "1",
        "DOTNET_CLI_USE_MSBUILD_SERVER": "0",
        "MSBUILDDISABLENODEREUSE": "1"
      },
      "directory": "<run dir>",
      "timeout_s": 60
    },
    "passes": "It exits 0 within 60 s and prints at least one line on standard output.",
    "output": "Standard output, with line endings as \\n, trailing spaces and blank lines removed, and the temporary directories' paths written as `.`; standard error is not recorded.",
    "placeholders": {
      "<run dir>": "a fresh, empty temporary directory: the program's working directory, deleted afterwards",
      "<build dir>": "a second fresh temporary directory, where a compiled sample is built",
      "$NAME": "a variable from the env.sh that scripts/samples/setup.sh writes (described in its header)"
    }
  }
}
