You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A side note on this is that when the tool doesn't exist you also get logging warnings:
2019-11-14 15:50:55.440 ERROR 44831 --- [ main] edu.ksu.canvas.net.SimpleRestClient : Object not found in Canvas. Requested URL: https://instance.instructure.com/api/v1/accounts/1/external_tools/789
2019-11-14 15:50:55.443 ERROR 44831 --- [ main] edu.ksu.canvas.net.SimpleRestClient : Body of error response from Canvas: {"errors":[{"message":"The specified resource does not exist."}]}
Yeah, the use of Optional for single object returns was questionable. Our team was pretty new to Java 8 and I'm not sure we did the right thing here. If you request an object that doesn't exist in Canvas, that is an error state that the calling application probably needs to know about. An exception allows you to pass back more details about the error so that the calling application might be able to handle it in some way. Just returning an empty Optional kind of leaves you hanging as to what actually happened. Doesn't exist? Not authorized to view as current user? Network problem?
I'm kind of tempted to remove it but of course that would break everything.
If I attempt to get an External Tool from Canvas using:
then if the tool doesn't exist in Canvas I don't get back an empty
Optional
but instead aedu.ksu.canvas.exception.ObjectNotFoundException
is thrown.It seems like either when the
toolId
doesn't exist we should either:Optional
Optional
or is there another reason why we should have both the
Optional
and the exception?The text was updated successfully, but these errors were encountered: