src/sydra/query/errors.zig
Purpose
Defines diagnostic structures for sydraQL validation.
See also
- Common utilities (
Span) - Validator (produces diagnostics)
- Orchestration entrypoint (returns
ValidationFailed)
Definition index (public)
pub const ErrorCode = enum { ... }
Current codes:
time_range_requiredunsupported_fill_policyinvalid_function_arityinvalid_syntaxunimplemented
Intended meaning (by convention in this repo):
time_range_required— missing or insufficienttimepredicateunsupported_fill_policy— fill clause exists but the policy is not supportedinvalid_function_arity— a function was called with the wrong number of argumentsinvalid_syntax— generic “this construct is not valid” diagnostic used by the validatorunimplemented— reserved for “recognized but not implemented yet”
pub const Diagnostic
code: ErrorCodemessage: []const u8— owned allocationspan: ?Span
Ownership note:
initDiagnosticclonesmessageusing the provided allocator.- Callers are responsible for freeing
diag.message(the validator does this inAnalyzer.deinit).
pub const DiagnosticList
Alias: std.ArrayListUnmanaged(Diagnostic)
pub fn initDiagnostic(alloc, code, message, span) !Diagnostic
Clones message into an owned allocation and returns a Diagnostic.
Tests
Inline tests validate that initDiagnostic clones the message buffer.
Code excerpt
src/sydra/query/errors.zig
pub const ErrorCode = enum {
time_range_required,
unsupported_fill_policy,
invalid_function_arity,
invalid_syntax,
unimplemented,
};
pub const Diagnostic = struct {
code: ErrorCode,
message: []const u8,
span: ?common.Span = null,
};
pub const DiagnosticList = std.ArrayListUnmanaged(Diagnostic);
pub fn initDiagnostic(alloc: std.mem.Allocator, code: ErrorCode, message: []const u8, span: ?common.Span) !Diagnostic {
const owned = try alloc.dupe(u8, message);
return .{ .code = code, .message = owned, .span = span };
}