Create a custom error type to support error levels
Created by: indradhanush
The error type should:
- Embed the original error and make it available to all consumers
- Have two levels:
warn
-
error
/critical
It remains to be decided which of the keywords, error
or critical
will be used to indicate the level. While using error
allows for a direct one to one mapping of expected logging level, that is log.Warn
for errors with warn
level and log.Error
for errors with error
level. However, the word error
itself makes for somewhat confusing code to read and write. For example:
if err.Level == "error" {
log.Error(err)
}
Versus
if err.Level == "critical" {
log.Error(err)
}
Having mentioned this, it remains a minor point and should not block the implementation of this issue. Choosing either is fine to start with and can be replaced easily if it feels like the other keyword is a better choice during the course of implementation of the overall Errors Classification project.