{"action":"created","issue":{"url":"https://api.github.com/repos/AliSoftware/OHPDFImage/issues/6","labels_url":"https://api.github.com/repos/AliSoftware/OHPDFImage/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/AliSoftware/OHPDFImage/issues/6/comments","events_url":"https://api.github.com/repos/AliSoftware/OHPDFImage/issues/6/events","html_url":"https://github.com/AliSoftware/OHPDFImage/issues/6","id":57338141,"number":6,"title":"Raising NSException","user":{"login":"colasjojo","id":4303814,"avatar_url":"https://avatars.githubusercontent.com/u/4303814?v=3","gravatar_id":"","url":"https://api.github.com/users/colasjojo","html_url":"https://github.com/colasjojo","followers_url":"https://api.github.com/users/colasjojo/followers","following_url":"https://api.github.com/users/colasjojo/following{/other_user}","gists_url":"https://api.github.com/users/colasjojo/gists{/gist_id}","starred_url":"https://api.github.com/users/colasjojo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colasjojo/subscriptions","organizations_url":"https://api.github.com/users/colasjojo/orgs","repos_url":"https://api.github.com/users/colasjojo/repos","events_url":"https://api.github.com/users/colasjojo/events{/privacy}","received_events_url":"https://api.github.com/users/colasjojo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-11T16:20:16Z","updated_at":"2015-02-11T23:04:27Z","closed_at":null,"body":"Hi Ali,\r\n\r\nwhat do you think of adding an exception in `OHVectorImage.m`: if the size has a zero-coordinate, we stop the process?\r\n\r\n```\r\n- (UIImage*)renderAtSize:(CGSize)size\r\n{\r\n    // Handle bad cases\r\n    if (size.width <= 0\r\n        ||\r\n        size.height <= 0)\r\n    {\r\n        [NSException raise:NSInvalidArgumentException\r\n                    format:@\"The size given must have positive coordinates\"] ;\r\n    }\r\n\r\n(... the normal method)\r\n}\r\n```\r\n\r\nAs one of my IBOutlet was not set, a zero size was given to the parameters. With this exception, I am able to detect very easily where the problem is."},"comment":{"url":"https://api.github.com/repos/AliSoftware/OHPDFImage/issues/comments/73984507","html_url":"https://github.com/AliSoftware/OHPDFImage/issues/6#issuecomment-73984507","issue_url":"https://api.github.com/repos/AliSoftware/OHPDFImage/issues/6","id":73984507,"user":{"login":"colasjojo","id":4303814,"avatar_url":"https://avatars.githubusercontent.com/u/4303814?v=3","gravatar_id":"","url":"https://api.github.com/users/colasjojo","html_url":"https://github.com/colasjojo","followers_url":"https://api.github.com/users/colasjojo/followers","following_url":"https://api.github.com/users/colasjojo/following{/other_user}","gists_url":"https://api.github.com/users/colasjojo/gists{/gist_id}","starred_url":"https://api.github.com/users/colasjojo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colasjojo/subscriptions","organizations_url":"https://api.github.com/users/colasjojo/orgs","repos_url":"https://api.github.com/users/colasjojo/repos","events_url":"https://api.github.com/users/colasjojo/events{/privacy}","received_events_url":"https://api.github.com/users/colasjojo/received_events","type":"User","site_admin":false},"created_at":"2015-02-11T23:04:27Z","updated_at":"2015-02-11T23:04:27Z","body":"Thanks for the answer and the explanations. I guess you are right.But, when the size is zero I get many errors in the console.Envoyé depuis Yahoo Mail pour iPadÀ 11 févr. 2015 23:42:43, AliSoftware a écrit :I'm not fond of exceptions, and, with the rise of Swift — which cannot catch exceptions — I tend to move away from them even more.\n\nBesides, one generally does not want its code to crash even when the size is zero width or height because it might be a case that actually happen (think about e.g. having to toggle a view's height to show/hide it for example, this view might have a zero-height when hidden and if it contains an UIImageView in which you render your OHPDFImage in it, you don't wan't your code to crash when you hide the view by changing its height to zero)\n\nIf you really want a reminder or helpful message when you use a zero-width or zero-height size, I'd probably rather have an NSLog to help the developer debug than an NSException.\n\n—Reply to this email directly or view it on GitHub."}}