Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upBetter error reporting #1071
Better error reporting #1071
Comments
|
Are these errors due to no matched routes found? Kitura sends 404 |
|
It might be that second option (none of the middleware/handlers sent data), but it would be nice to know why that happened. Some examples I encountered include:
|
|
Can I add some weight to this issue? I have wasted hours trying to debug even the simplest bugs, simply because Kitura does not print any errors in its log. I am using |
|
I have tried using I did notice there's a line that sets the error in |
|
I figured out the cause of my problem.
When a handler throws an error, that deferred So now I'm wondering if I'm using |
|
I've found that I need to put a breakpoint on this line to find errors. Could we just add logging to this one line? https://github.com/IBM-Swift/Kitura/blob/master/Sources/Kitura/RouterMiddlewareWalker.swift#L67
|
|
@bridger What did you end up doing? With my custom error class I have an enum // Handles any errors that get set
router.error { request, response, next in
let errorDescription: String
if let error = response.error as? MyServiceError {
errorDescription = error.debugDescription
response.status(error.errorStatus)
} else if let error = response.error {
errorDescription = error.localizedDescription
} else {
errorDescription = "Unknown error"
}
try response.send(json: JSON(["error": errorDescription])).end()
} |
|
@christiancompton can you pick this up? |
|
As I play with 2.0, I'm seeing a limitation with codables. If I want to return a custom object in the case of an error. Rather than returning router.post("/endpoint") { (codables: [MyCodable], respondWith: ([MyCodable?], RequestError?) -> Void ) in
if !codables.isEmpty {
do {
let newCodables = try self.createOrUpdate(codables) // add to db
respondWith(newCodables, nil) // return successfully updated models
} catch {
respondWith([], .internalServerError) // here i'd like to return an error obj rather than a MyCodable
}
}
respondWith(codables, nil)
}I guess I could solve this by creating a Codable which contains a variable for data and one for status. So... {
"data" : [ { "id": 1}, { "id": 2}, {"id": 2} ],
"status": { "success": 1, "message" : "this is where an error msg could go on failure" }
}Maybe this is the way to do things, though it adds a bit of complication to my api |


I'm in the process of writing my first (real) Kitura app and have been lost quite a lot. Kitura often sends
Cannot GET /some/endpoint.responses without any error message in the log to help debug the issue. My log consists almost exclusively of[VERBOSE] [HTTPServerRequest.swift:215 parsingCompleted()] HTTP request from=127.0.0.1; proto=http;messages, even when there have been errors. I am using HeliumLogger and have tried different log levels but have never seen an actual error message.