{"action":"created","issue":{"url":"https://api.github.com/repos/IBM-Swift/Kitura/issues/1071","repository_url":"https://api.github.com/repos/IBM-Swift/Kitura","labels_url":"https://api.github.com/repos/IBM-Swift/Kitura/issues/1071/labels{/name}","comments_url":"https://api.github.com/repos/IBM-Swift/Kitura/issues/1071/comments","events_url":"https://api.github.com/repos/IBM-Swift/Kitura/issues/1071/events","html_url":"https://github.com/IBM-Swift/Kitura/issues/1071","id":221944033,"number":1071,"title":"Better error reporting","user":{"login":"svanimpe","id":1496250,"avatar_url":"https://avatars3.githubusercontent.com/u/1496250?v=4","gravatar_id":"","url":"https://api.github.com/users/svanimpe","html_url":"https://github.com/svanimpe","followers_url":"https://api.github.com/users/svanimpe/followers","following_url":"https://api.github.com/users/svanimpe/following{/other_user}","gists_url":"https://api.github.com/users/svanimpe/gists{/gist_id}","starred_url":"https://api.github.com/users/svanimpe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svanimpe/subscriptions","organizations_url":"https://api.github.com/users/svanimpe/orgs","repos_url":"https://api.github.com/users/svanimpe/repos","events_url":"https://api.github.com/users/svanimpe/events{/privacy}","received_events_url":"https://api.github.com/users/svanimpe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"christiancompton","id":18534315,"avatar_url":"https://avatars1.githubusercontent.com/u/18534315?v=4","gravatar_id":"","url":"https://api.github.com/users/christiancompton","html_url":"https://github.com/christiancompton","followers_url":"https://api.github.com/users/christiancompton/followers","following_url":"https://api.github.com/users/christiancompton/following{/other_user}","gists_url":"https://api.github.com/users/christiancompton/gists{/gist_id}","starred_url":"https://api.github.com/users/christiancompton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christiancompton/subscriptions","organizations_url":"https://api.github.com/users/christiancompton/orgs","repos_url":"https://api.github.com/users/christiancompton/repos","events_url":"https://api.github.com/users/christiancompton/events{/privacy}","received_events_url":"https://api.github.com/users/christiancompton/received_events","type":"User","site_admin":false},"assignees":[{"login":"christiancompton","id":18534315,"avatar_url":"https://avatars1.githubusercontent.com/u/18534315?v=4","gravatar_id":"","url":"https://api.github.com/users/christiancompton","html_url":"https://github.com/christiancompton","followers_url":"https://api.github.com/users/christiancompton/followers","following_url":"https://api.github.com/users/christiancompton/following{/other_user}","gists_url":"https://api.github.com/users/christiancompton/gists{/gist_id}","starred_url":"https://api.github.com/users/christiancompton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christiancompton/subscriptions","organizations_url":"https://api.github.com/users/christiancompton/orgs","repos_url":"https://api.github.com/users/christiancompton/repos","events_url":"https://api.github.com/users/christiancompton/events{/privacy}","received_events_url":"https://api.github.com/users/christiancompton/received_events","type":"User","site_admin":false}],"milestone":null,"comments":8,"created_at":"2017-04-15T11:51:29Z","updated_at":"2017-11-08T23:28:59Z","closed_at":null,"author_association":"NONE","body":"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."},"comment":{"url":"https://api.github.com/repos/IBM-Swift/Kitura/issues/comments/342996444","html_url":"https://github.com/IBM-Swift/Kitura/issues/1071#issuecomment-342996444","issue_url":"https://api.github.com/repos/IBM-Swift/Kitura/issues/1071","id":342996444,"user":{"login":"tettoffensive","id":5884119,"avatar_url":"https://avatars3.githubusercontent.com/u/5884119?v=4","gravatar_id":"","url":"https://api.github.com/users/tettoffensive","html_url":"https://github.com/tettoffensive","followers_url":"https://api.github.com/users/tettoffensive/followers","following_url":"https://api.github.com/users/tettoffensive/following{/other_user}","gists_url":"https://api.github.com/users/tettoffensive/gists{/gist_id}","starred_url":"https://api.github.com/users/tettoffensive/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tettoffensive/subscriptions","organizations_url":"https://api.github.com/users/tettoffensive/orgs","repos_url":"https://api.github.com/users/tettoffensive/repos","events_url":"https://api.github.com/users/tettoffensive/events{/privacy}","received_events_url":"https://api.github.com/users/tettoffensive/received_events","type":"User","site_admin":false},"created_at":"2017-11-08T23:28:59Z","updated_at":"2017-11-08T23:28:59Z","author_association":"NONE","body":"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 `MyCodable`, I'd like to return something like `{ \"error\": \"this is the reason it errored\"}`.\r\n\r\n```swift\r\nrouter.post(\"/endpoint\") { (codables: [MyCodable], respondWith: ([MyCodable?], RequestError?) -> Void ) in\r\n      if !codables.isEmpty {\r\n        do {\r\n          let newCodables = try self.createOrUpdate(codables) // add to db\r\n         respondWith(newCodables, nil) // return successfully updated models\r\n        } catch {\r\n          respondWith([], .internalServerError) // here i'd like to return an error obj rather than a MyCodable\r\n        }\r\n      }\r\n      respondWith(codables, nil)\r\n    }\r\n```\r\n\r\nI guess I could solve this by creating a Codable which contains a variable for data and one for status.\r\n\r\nSo...\r\n\r\n```json\r\n{ \r\n \"data\" : [ { \"id\": 1}, { \"id\": 2}, {\"id\": 2} ],\r\n \"status\": { \"success\": 1, \"message\" : \"this is where an error msg could go on failure\" }\r\n}\r\n```\r\n\r\nMaybe this is the way to do things, though it adds a bit of complication to my api"}}
{"actor":{"display_login":"tettoffensive"}}