Skip to content

Commit e1213ca

Browse files
vbilopavclaude
andcommitted
Add Critical log before process exit on SQL file errors, update changelog
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0732a21 commit e1213ca

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ Override with the `@path` annotation: `-- @path /custom/path/{id}`
230230
| `ParseErrorMode.Exit` (default) | Logs error, exits process | Fail-fast — catches SQL errors at startup |
231231
| `ParseErrorMode.Skip` | Logs error, skips file, continues | Production — tolerate partial failures |
232232

233+
All SQL file errors are logged at `Error` level. In `Exit` mode, a `Critical` log explains the exit and how to switch to `Skip` mode.
234+
235+
A warning is logged when the configured file pattern matches no files.
236+
233237
Errors caught at startup:
234238
- Parse errors (malformed SQL, unclosed strings/quotes)
235239
- Describe errors (PostgreSQL syntax errors, invalid table/column references)

plugins/NpgsqlRest.SqlFileSource/SqlFileSource.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class SqlFileSource(SqlFileSourceOptions options) : IEndpointSource
5757
NpgsqlRestOptions.Logger?.LogError("SqlFileSource: Error processing file {FilePath}: {Error}", filePath, ex.Message);
5858
if (options.ErrorMode == ParseErrorMode.Exit)
5959
{
60+
NpgsqlRestOptions.Logger?.LogCritical("SqlFileSource: Exiting due to SQL file error. Set ErrorMode to Skip to continue past errors.");
6061
Environment.Exit(1);
6162
}
6263
}
@@ -94,6 +95,7 @@ private static (Routine, IRoutineSourceParameterFormatter)? ProcessFile(
9495
}
9596
if (options.ErrorMode == ParseErrorMode.Exit)
9697
{
98+
NpgsqlRestOptions.Logger?.LogCritical("SqlFileSource: Exiting due to SQL file error. Set ErrorMode to Skip to continue past errors.");
9799
Environment.Exit(1);
98100
}
99101
return null;
@@ -122,6 +124,7 @@ private static (Routine, IRoutineSourceParameterFormatter)? ProcessFile(
122124
NpgsqlRestOptions.Logger?.LogError("SqlFileSource: {FilePath}: Describe failed: {Error}", filePath, describeResult.Error);
123125
if (options.ErrorMode == ParseErrorMode.Exit)
124126
{
127+
NpgsqlRestOptions.Logger?.LogCritical("SqlFileSource: Exiting due to SQL file error. Set ErrorMode to Skip to continue past errors.");
125128
Environment.Exit(1);
126129
}
127130
return null;
@@ -143,6 +146,7 @@ private static (Routine, IRoutineSourceParameterFormatter)? ProcessFile(
143146
NpgsqlRestOptions.Logger?.LogError("SqlFileSource: {FilePath}: {Error}", filePath, error);
144147
if (options.ErrorMode == ParseErrorMode.Exit)
145148
{
149+
NpgsqlRestOptions.Logger?.LogCritical("SqlFileSource: Exiting due to SQL file error. Set ErrorMode to Skip to continue past errors.");
146150
Environment.Exit(1);
147151
}
148152
return null;

0 commit comments

Comments
 (0)