SetPathIfEmpty sets error's path with the given path item as the only item in path, only if initially the error had no path.
(err error, pathItem interface{})
| 133 | // SetPathIfEmpty sets error's path with the given path item as the only item in path, |
| 134 | // only if initially the error had no path. |
| 135 | func SetPathIfEmpty(err error, pathItem interface{}) error { |
| 136 | gqlErrs := AsGQLErrors(err) |
| 137 | for _, e := range gqlErrs { |
| 138 | if len(e.Path) == 0 { |
| 139 | e.Path = []interface{}{pathItem} |
| 140 | } |
| 141 | } |
| 142 | return gqlErrs |
| 143 | } |
| 144 | |
| 145 | // PrependPath adds the given path item as the first item in the error's path list. |
| 146 | func PrependPath(err error, pathItem interface{}) error { |
no test coverage detected