]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_codesigning/lib/cserror.cpp
   2  * Copyright (c) 2007,2011 Apple Inc. All Rights Reserved. 
   4  * @APPLE_LICENSE_HEADER_START@ 
   6  * This file contains Original Code and/or Modifications of Original Code 
   7  * as defined in and that are subject to the Apple Public Source License 
   8  * Version 2.0 (the 'License'). You may not use this file except in 
   9  * compliance with the License. Please obtain a copy of the License at 
  10  * http://www.opensource.apple.com/apsl/ and read it before using this 
  13  * The Original Code and all software distributed under the License are 
  14  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  15  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  16  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 
  17  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  18  * Please see the License for the specific language governing rights and 
  19  * limitations under the License. 
  21  * @APPLE_LICENSE_HEADER_END@ 
  25 // cserror.h - extended-diagnostics Code Signing errors 
  28 #include <security_utilities/cfmunge.h> 
  31 namespace CodeSigning 
{ 
  35 // We need a nothrow destructor 
  37 CSError::~CSError() throw () 
  42 // Create and throw various forms of CSError 
  44 void CSError::throwMe(OSStatus rc
) 
  49 void CSError::throwMe(OSStatus rc
, CFDictionaryRef dict
) 
  51         throw CSError(rc
, dict
); 
  54 void CSError::throwMe(OSStatus rc
, CFStringRef key
, CFTypeRef value
) 
  56         throw CSError(rc
, cfmake
<CFDictionaryRef
>("{%O=%O}", key
, value
)); 
  61 // Add a key/value pair to the dictionary 
  63 void CSError::augment(CFStringRef key
, CFTypeRef value
) 
  65         mInfoDict
.take(cfmake
<CFDictionaryRef
>("{+%O,%O=%O}", mInfoDict
.get(), key
, value
)); 
  70 // Convert exception-carried error information to CFError form 
  72 OSStatus 
CSError::cfError(CFErrorRef 
*errors
) const 
  74         if (errors
)             // errors argument was specified 
  75                 *errors 
= CFErrorCreate(NULL
, kCFErrorDomainOSStatus
, this->osStatus(), this->infoDict()); 
  76         return this->osStatus(); 
  79 OSStatus 
CSError::cfError(CFErrorRef 
*errors
, OSStatus rc
) 
  82                 *errors 
= CFErrorCreate(NULL
, kCFErrorDomainOSStatus
, rc
, NULL
);