-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Right now all logging of error types must take the form clog.error(message, error), requiring providing a message. But for strongly typed errors, the "message" may just be a restatement of the "type" of the error to some degree, i.e.
func operationFailed(_ error: NetworkError) {
clog.error("Network error", error)
}
func otherOperationFailed(_ error: SpecificError) {
switch error {
case .a : clog.error("failure A", error)
case .b : clog.error("failure B", error)
}
}
On one project, we did add direct support for this sort of thing at the app level by adding a type that provides a description, something like:
protocol LoggableError: Error {
var typeDescription: StaticString { get }
}
which would allow adding a
func error(_ selfDescribingError: LoggableError) {
error(selfDescribingError.typeDescription, selfDescribingError)
}
that doesn't need a message. It might be useful to support this at the Steamclog level.
Metadata
Metadata
Assignees
Labels
No labels