UUID::makeBin() actually supports a wider range of string representations for UUIDs (although it's not as strict on this particular form), so you may just want to use that and thow an exception if it returns false.