Databin
does not evaluate when the bin does not exist. Calling it with an invalid id
err = Databin["13X7XXXJH"]
does not result in err=$Failure
as one might expect but rather remains unevaluated as Databin["13X7XXXJH"]
and calling err
again results in the at this point already issued error message. For checking validity of a bin this is as discovered in this question rather unpleasant. I tried using Check
, FailureQ
, etc. without success. To be honest I am not sure if Databin
is implemented correctly/properly in this regard because the output after Databin::apierr
strongly suggests err=$Failure
.
I proceed by looking under the hood of Databin
using PrintDefinitions
from the GeneralUtilities
package and I found the subroutine which checks id strings for validity:
err=Catch@DataDropClient`Private`getBinID["13X7XXXJH"]
evaluates to $Failed
with the specific error message Databin::nobin
. Using getBinID
one can define
DatabinCheck[s_String]:=Catch@Quiet[DataDropClient`Private`getBinID[s],Databin::nobin]
which returns a complete UUID string if s
is the id of an existing Databin and $Failed
(without printing and error message) if s
is invalid. One might use StringQ
or FailureQ
on the result to check it. Another option would be to use something like
DatabinCheck[s_String]:=Quiet[Check[Catch@DataDropClient`Private`getBinID[s],failexpr,Databin::nobin],Databin::nobin]
to return (or call) failexpr
directly from within DatabinCheck
.
Using the internal method getBinID
might introduce some overhead and might not be very robust (given that it is an internal function which might/is change/d in future/past versions). Catching the Databin::apierr
thrown by Databin
itself seems much more elegant but I could not get this to work as discussed earlier.