How do I setup an MPErrorDomain listener - objective-c

I'm trying to understand how to handle errors in obj-c on the MediaPlayer and we had someone do some work to do this for us on the AVPlayer but the way that is handled on AVPlayer is different, from what I can see in the documentation, than how errors are handled on the MPMusicPlayerController.
There is something called an MPErrorDomain which is a type of ErrorDomain.
https://developer.apple.com/documentation/mediaplayer/mperrordomain?language=objc
Do I create an observer to listen for when this type of error object occurs?
I am really just looking to understand how to process when one of these errors occur
https://developer.apple.com/documentation/mediaplayer/mperrorcode?language=objc
Ultimately I want to process these error codes
https://developer.apple.com/documentation/mediaplayer/mperrorcode?language=objc

Do I create an observer to listen for when this type of error object occurs?
No. You just do stuff and either you get an error or you don't.
Some methods have error parameters in their completion handlers:
https://developer.apple.com/documentation/mediaplayer/mpmusicplayercontroller/2582424-preparetoplay
https://developer.apple.com/documentation/mediaplayer/mpmusicplayerapplicationcontroller/2815055-perform
Apart from that, you'll know you've got an error because the Console will say so (during debugging with Xcode).

Related

How to tell default error handler to stop logging to the console?

This is about NodeJS and Express. I want to add an error handler that simply logs the error in my preferred way. This way also takes care of console output. I don't want, at this point in time anyway, to replace the functionality of the Express default error handler. I want the default error handler to continue doing its thing for the time being, with one exception: Since my logging already took place, and also covers console output, I want the default error handler to pretty much stop adding to the console.
My question is: How do I accomplish this? I did some searching and found nothing, so unsure if I may be using the wrong keywords.

How can I display exception messages from custom functoid errors in the BizTalk Administration Console?

My goal is to influence the error descriptions that appear in BizTalk Administration Console in the Error Information tab of suspended instance windows, after errors occur in my custom functoids. If possible, I would also like the ErrorReport.Description promoted property to display this error description on the failed message.
I've read everything I can find about custom functoid development, but I can't find much about error handling within them. In particular, whenever my functoids throw exceptions, I see the boilerplate "Exception has been thrown at the target of an invocation" message that occurs whenever exceptions occur through reflection, rather than the message on the exception itself.
I had hoped to find something within the BaseFunctoid class framework that would allow me to submit an error string, so as to traverse the reflection boundary. Is there some way to pass error information from within a custom functoid, such that the BizTalk Administration Console will display it?
If I emulate the approach taken by DatabaseLookupFunctoid and DatabaseErrorExtractFunctoid, is there some way I can fail the map with the extracted error, rather than mapping it to a field on the destination schema as is shown in its examples?
The simplest way to do this is using custom C#, writing something like this in your code:
System.Diagnostics.EventLog.WriteEntry("EVENT_LOG_SOURCE", "Error message...", System.Diagnostics.EventLogEntryType.Error);
As Johns-305 mentions, you need to make sure your event source is registered (e.g. System.Diagnostics.EventLog.CreateEventSource("EVENT_LOG_SOURCE", "Application") - but this should really be done as part of your installation steps with an EventLogInstaller or some kind of script to set up the environment). It's certainly true that error handling in BizTalk is just .NET error handling, but one thing to keep in mind is that maps are actually executing as XSLT, and the context in which their executing can have a major impact on how exceptions and errors will be handled, particularly unhandled exceptions.
Orchestrations
If you're executing a transform in an orchestration that has exception handling in it, the exception thrown will be handled and may even fall into additional logging you have in the orchestration - in other words, executing a throw from a C# functiod will work the way you'd think it would work elsewhere in C#. However, I try to avoid this since you never know if a map will at some point be used else where and because exception handling in XSLT doesn't always work the way you'd think (see below).
Send/Receive Ports
Unfortunately, if you're executing a map on a send or receive port and throw an exception within it, you will almost definitely get very unhelpful error message in the event log and a suspended instance in the group hub. There is no easy, straightforward way to simple "cancel" a transform - XSLT 1.0 doesn't have any specified way of doing that (see for example Throwing an exception from XSLT). That leaves you with outputting an error string to a particular node in the output (and/or to the EventLog), or writing lots of completely custom XSLT to try to validate input, or designing your schemas properly and using a validating component where necessary. For example, if you have a node that must match a particular regex, or should never be empty, or should never repeat more than X times, make sure you set those restrictions on the schema and then make sure you pass it through the XmlValidator or similar before attempting to map.
The simplest answer is, you just do.
Keep in mind, there is nothing special at all about error handling in BizTalk apps, it's just regular plain old .Net error handling.
So, what you do is catch the error in you code, write the details to the Windows Event Log (be sure to create a custom Event Source) and...that's it. That is all I do. I don't worry about what appear in BT Admin specifically.strong text

Download progress with WinHttp.WinHttpRequest.5.1

Is there a way to find out how much of a GET request has been received? I can't do Len(.ResponseBody) until it's complete, so that's not possible.
I was researching how you could bind to IWinHttpRequestEvents. The OnResponseDataAvailable event is exactly what you need. It would give you the data as it came in. Then, you could handle it however you like.
Unfortunately, trying to bind to that event interface causes VBScript to crash with a C0000005 GPF. I also found a reference to it crashing in a different language. So, I can't say whether this would work in VBA or VB6 or any other language. Details are discussed in following question.
WScript.CreateObject crashes Windows Scripting Host when event handler prefix is specified for WinHTTPRequest
The alternative is to switch to Msxml2.XMLHTTP or Msxml2.ServerXMLHTTP. These objects come with a property named readyState that will give you some idea of what is happening to the download. It won't give you the current number of bytes downloaded, but it's something.
Additionally, there you can trap the onReadyStateChange event, which will let you know when the readyState on the object has changed. Microsoft has even provided sample code for trapping the event.

server problem in objective-c

I am hitting an url when the server shutdown.Then the program hang up.May i know how to handle the error when the server shutdown.I mean at that situation I want to give an alert.
Thanks in advance
this is in objective-c
Check reachability api code example in cocoa documentation.
The delegate you supply to an NSURLConnection should handle the error. It will receive the -connection:didFailWithError: message in the event that anything goes wrong. Listing 4 here gives a simple example of just logging the error. If you want an alert dialog to appear you can just sent -presentError: with the NSError as a parameter to a view or a NSDocumentController.

Error handling in wxWidgets

Could someone provide info about error-handling in wxWidgets or a pointer to documentation?
Specifically, I discovered this behavior: I try to create a wxImage from a file. This is in an event-handler. The file is not present. The call to the image constructor does not throw an exception. (I understand that no wxWidgets code throws exceptions.) A call to image.Ok() returns false. Fine. But after my event-handler exits, wxWidgets gratuitously pops up an error message dialog. That's okay for this particular application, but I wonder how to stop that from happening if I want to handle the error myself. I suspect that the dialog is coming from an event-handler, but I search for things like EVT_ERROR, and came up empty.
There is the class wxLogNull for suppressing those log messages. See http://docs.wxwidgets.org/stable/wx_wxlognull.html#wxlognull where also an example is given.
Read the wxLog overview for more details on how wxWidgets handles this.
You can define your own log target which would throw an exception if an error message is logged. Of course, then you'd probably need to catch it in your event handler anyhow as you probably don't want to just give the user a relatively useless "File couldn't be opened" message but rather a "Image couldn't be opened" one. And if you do this, then why not just test for file.IsOk() directly and use wxLogError() yourself? IOW you can do what you want but I don't really see how is it better than the traditional exception-less way of doing things in this particular case.