[Mono-bugs] [Bug 656088] New: NSError "Keys" not translated into Monotouch.Foundation

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Nov 26 07:40:35 EST 2010


https://bugzilla.novell.com/show_bug.cgi?id=656088

https://bugzilla.novell.com/show_bug.cgi?id=656088#c0


           Summary: NSError "Keys" not translated into
                    Monotouch.Foundation
    Classification: Mono
           Product: MonoTouch
           Version: unspecified
          Platform: Macintosh
        OS/Version: Mac OS X 10.6
            Status: NEW
          Severity: Minor
          Priority: P5 - None
         Component: Class Libraries
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: johan.otto at justenough.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Beta-Customer
           Blocker: ---


When consuming NSError exceptions raised by Objective-C, I wrote an exception
class to translate the NSError to a Exception to make exception handling
uniform.

I was expecting the following NSError constants to be on the NSError class. Am
I missing the location of these constants or were they not translated into
MonoTouch?

NSString * const NSLocalizedDescriptionKey;
NSString * const NSErrorFailingURLStringKey;
NSString * const NSFilePathErrorKey;
NSString * const NSStringEncodingErrorKey;
NSString * const NSUnderlyingErrorKey;
NSString * const NSURLErrorKey;
NSString * const NSLocalizedFailureReasonErrorKey;
NSString * const NSLocalizedRecoverySuggestionErrorKey;
NSString * const NSLocalizedRecoveryOptionsErrorKey;
NSString * const NSRecoveryAttempterErrorKey;
NSString * const NSHelpAnchorErrorKey;
NSString * const NSURLErrorFailingURLErrorKey;
NSString * const NSURLErrorFailingURLStringErrorKey;
NSString * const NSURLErrorFailingURLPeerTrustErrorKey;

------ My Exception Class --
/// <summary>
    ///   Convenient exception wrapper for a <see cref="NSError"/>.
    /// </summary>
    public class NSErrorException: Exception
    {
        #region Construction
        /// <summary>
        ///   Initialize a new instance of <see cref="NSErrorException"/>.
        /// </summary>
        /// <param name="error">
        /// A <see cref="NSError"/>
        /// </param>
        public NSErrorException(NSError error):this(error != null ?
error.LocalizedDescription : "Unknown ObjC Error", error)
        {
            if (error != null)
            {
                ConsumeNSError(error);
            }

        }

        /// <summary>
        ///   Initialize a new instance of <see cref="NSErrorException"/>.
        /// </summary>
        /// <param name="message">
        /// A <see cref="System.String"/>
        /// </param>
        /// <param name="error">
        /// A <see cref="NSError"/>
        /// </param>
        public NSErrorException (string message, NSError error):base(message)
        {
            _errorObject = error;
        }
        #endregion

        #region ConsumeNSError
        /// <summary>
        ///   Consume the NSError to get a better 'visual' representation.
        /// </summary>
        private void ConsumeNSError(NSError error)
        {
            // Turn NSError to something friendlier:
http://www.cimgf.com/2008/05/19/cocoa-tutorial-expanding-nserror-usage/
            // ?? Missing NS Error constants
            /*
             *NSString * const NSLocalizedDescriptionKey;
NSString * const NSErrorFailingURLStringKey;
NSString * const NSFilePathErrorKey;
NSString * const NSStringEncodingErrorKey;
NSString * const NSUnderlyingErrorKey;
NSString * const NSURLErrorKey;
NSString * const NSLocalizedFailureReasonErrorKey;
NSString * const NSLocalizedRecoverySuggestionErrorKey;
NSString * const NSLocalizedRecoveryOptionsErrorKey;
NSString * const NSRecoveryAttempterErrorKey;
NSString * const NSHelpAnchorErrorKey;
NSString * const NSURLErrorFailingURLErrorKey;
NSString * const NSURLErrorFailingURLStringErrorKey;
NSString * const NSURLErrorFailingURLPeerTrustErrorKey;*/
        }
        #endregion

        #region StackTrace
        private string _stackTrace = string.Empty;
        /// <summary>
        /// The stack trace when the exception occured
        /// </summary>
        /// <value></value>
        public override string StackTrace
        {
            get
            {
                return _stackTrace; //base.StackTrace;
            }
        }
        #endregion



        #region ErrorObject
        private NSError _errorObject;
        /// <summary>
        /// Get a value for ErrorObject.
        /// </summary>
        public NSError ErrorObject
        {
            get { return _errorObject; }
        }
        #endregion
    }

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list