Throw ObjectNotFoundException from FindRequired; add run-console wrappers
- DbBase.FindRequired / Client.FindByNameRequired now throw the domain-specific ObjectNotFoundException (NHibernate lineage; Rails equivalent: ActiveRecord::RecordNotFound) on a lookup miss; the no-context case stays InvalidOperationException (configuration error) - Console demo catches the new type; tests (18)/(21) assert it, (19)/(23) keep InvalidOperationException with rationale comments - scripts/run-console.sh delegates to dotnet.sh; run-console.ps1 is the Windows/PowerShell counterpart (mise-first, repo-root cd) Yak: objectnotfoundexception-run-console-wrappers-3p8b
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
# Run the Before.Console demo app (src/Before.Console/Program.cs) on Windows.
|
||||
#
|
||||
# Windows counterpart of scripts/run-console.sh:
|
||||
# - runs from the repo root, like the other scripts
|
||||
# - prefers mise (see mise.toml) and falls back to a dotnet on PATH
|
||||
#
|
||||
# Troubleshooting: if dotnet fails with "The user's home directory could not
|
||||
# be determined" (some sandboxed shells), set DOTNET_CLI_HOME first:
|
||||
# PS> $env:DOTNET_CLI_HOME = "$PWD\.dotnet-cli"
|
||||
#
|
||||
# Usage (from anywhere):
|
||||
# PS> .\scripts\run-console.ps1 # no args
|
||||
# PS> .\scripts\run-console.ps1 --verbose # args go to the program
|
||||
# The script inserts the `--` separator for dotnet run itself.
|
||||
#
|
||||
# If script execution is blocked by policy:
|
||||
# PS> powershell -ExecutionPolicy Bypass -File .\scripts\run-console.ps1
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
Push-Location $repoRoot
|
||||
try {
|
||||
$dotnetArgs = @('run', '--project', 'src/Before.Console')
|
||||
if ($args.Count -gt 0) {
|
||||
$dotnetArgs += '--'
|
||||
$dotnetArgs += $args
|
||||
}
|
||||
|
||||
if (Get-Command mise -ErrorAction SilentlyContinue) {
|
||||
mise exec -- dotnet @dotnetArgs
|
||||
}
|
||||
else {
|
||||
dotnet @dotnetArgs
|
||||
}
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run the Before.Console demo app (src/Before.Console/Program.cs).
|
||||
# Delegates to scripts/dotnet.sh — see there for why the wrapper exists
|
||||
# (mise-installed dotnet, DOTNET_CLI_HOME, run from repo root).
|
||||
#
|
||||
# Usage: scripts/run-console.sh [app args]
|
||||
# scripts/run-console.sh # no args
|
||||
# scripts/run-console.sh -- --verbose # args are passed to the program
|
||||
set -euo pipefail
|
||||
exec "$(cd "$(dirname "$0")" && pwd)/dotnet.sh" run --project src/Before.Console -- "$@"
|
||||
Reference in New Issue
Block a user