Skip to content

Commit 4182f8a

Browse files
committed
fix: error handling
1 parent 4b746f4 commit 4182f8a

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The extension is a DuckDB Community Extension using `popen()` for process pipes.
1212

1313
## Build Commands
1414

15+
This extension does not use vcpkg.
16+
1517
```bash
1618
# Build release version
1719
GEN=ninja make release

src/shell_file_system.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace duckdb
7373

7474
if (input.empty() || input.back() != '|')
7575
{
76-
throw std::runtime_error("Command must end with '|'.");
76+
throw InvalidInputException("Command must end with '|'.");
7777
}
7878

7979
std::string marker = "{allowed_exit_codes=";
@@ -103,16 +103,24 @@ namespace duckdb
103103

104104
if (!isNonNegativeInteger(token))
105105
{
106-
throw std::runtime_error("Invalid exit code: '" + token + "'. Must be a non-negative integer.");
106+
throw InvalidInputException("Invalid exit code: '%s'. Must be a non-negative integer.", token);
107107
}
108108

109-
int value = std::stoi(token);
109+
int value;
110+
try
111+
{
112+
value = std::stoi(token);
113+
}
114+
catch (const std::out_of_range &)
115+
{
116+
throw InvalidInputException("Exit code out of range: '%s'. Value too large.", token);
117+
}
110118
result.allowed_exit_codes.insert(value); // deduplicated automatically
111119
}
112120

113121
if (result.allowed_exit_codes.empty())
114122
{
115-
throw std::runtime_error("No valid exit codes parsed.");
123+
throw InvalidInputException("No valid exit codes parsed.");
116124
}
117125

118126
return result;

src/shellfs_extension.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace duckdb
2323
// When writing to a PIPE ignore the SIGPIPE error and consider that the write succeeded.
2424
config.AddExtensionOption("ignore_sigpipe", "Ignore SIGPIPE", LogicalType::BOOLEAN, Value(false));
2525

26-
QueryFarmSendTelemetry(loader, "shellfs", "2025120401");
26+
QueryFarmSendTelemetry(loader, "shellfs", "2025120402");
2727
}
2828

2929
void ShellfsExtension::Load(ExtensionLoader &loader)

0 commit comments

Comments
 (0)