Add public facade value wrappers
This commit is contained in:
44
internal/facade/diagnostic.go
Normal file
44
internal/facade/diagnostic.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package configkit
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"gitea.maximumdirect.net/eric/ConfigKit/internal/engine"
|
||||
)
|
||||
|
||||
// LoadError reports safe structured diagnostics for a failed configuration load.
|
||||
type LoadError struct{ value *engine.LoadError }
|
||||
|
||||
func (e *LoadError) Error() string {
|
||||
if e == nil || e.value == nil {
|
||||
return "configkit: configuration load failed"
|
||||
}
|
||||
return e.value.Error()
|
||||
}
|
||||
func (e *LoadError) Diagnostics() []Diagnostic {
|
||||
if e == nil || e.value == nil {
|
||||
return nil
|
||||
}
|
||||
values := e.value.Diagnostics()
|
||||
result := make([]Diagnostic, len(values))
|
||||
for i := range values {
|
||||
result[i] = fromEngineDiagnostic(values[i])
|
||||
}
|
||||
return result
|
||||
}
|
||||
func (e *LoadError) Sources() []SourceInfo {
|
||||
if e == nil || e.value == nil {
|
||||
return nil
|
||||
}
|
||||
values := e.value.Sources()
|
||||
result := make([]SourceInfo, len(values))
|
||||
for i := range values {
|
||||
result[i] = fromEngineSourceInfo(values[i])
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// WriteDiagnostics writes diagnostics in canonical order.
|
||||
func WriteDiagnostics(output io.Writer, diagnostics []Diagnostic) error {
|
||||
return engine.WriteDiagnostics(output, toEngineDiagnostics(diagnostics))
|
||||
}
|
||||
Reference in New Issue
Block a user