@cryptotaxi247 / kubo / commits / 807ffb914

commands/dns: return NotFound error for failed resolutions

License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>

Lars Gierth committed Mar 11, 2017 at 04:48 UTC 807ffb9141909a081c651c8cf519d0ae50401971
2 files changed +5
commands/response.go
+1
@@ -17,6 +17,7 @@ type ErrorType uint
17 const (
18 ErrNormal ErrorType = iota // general errors
19 ErrClient // error was caused by the client, (e.g. invalid CLI usage)
20 + ErrNotFound // == HTTP 404 Not Found
21 ErrImplementation // programmer error in the server
22 // TODO: add more types of errors for better error-specific handling
23 )
core/commands/dns.go
+4
@@ -60,6 +60,10 @@ The resolver can recursively resolve:
60 depth = namesys.DefaultDepthLimit
61 }
62 output, err := resolver.ResolveN(req.Context(), name, depth)
63 + if err == namesys.ErrResolveFailed {
64 + res.SetError(err, cmds.ErrNotFound)
65 + return
66 + }
67 if err != nil {
68 res.SetError(err, cmds.ErrNormal)
69 return