Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

SerializationException when MailChimp returns error page instead of an API result #155

Open
htoomik opened this issue Apr 22, 2015 · 2 comments

Comments

@htoomik
Copy link

htoomik commented Apr 22, 2015

In some cases (and I haven't been able to determine when this happens) MailChimp returns an error page instead of an API response - html instead of json. Possibly when the service is down?

MailChimpManager throws SerializationException when this happens.
It would be nicer to get a MailChimpAPIException of some kind, ideally including the first n characters of the page body.

This is the exception we get:

System.Runtime.Serialization.SerializationException : Type definitions should start with a '{', expecting serialized type 'ApiError', got string starting with: <HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>
An e...
@danesparza
Copy link
Owner

This is a great point. It'd be nice if we could get an easily reproducible case. The next time this happens, can you see if it's dropping into this exception handler here?

If it is, we could probably add another check to see if it's a JSON based response or not. First 'n' characters of the page body might be a bit interesting to pull out (do you have an HTML parser in mind for that?)

@htoomik
Copy link
Author

htoomik commented Apr 23, 2015

Yes, it looks like that's where we end up. Here's my stack trace:

System.AggregateException: One or more errors occurred. ---> System.Runtime.Serialization.SerializationException: Type definitions should start with a '{', expecting serialized type 'ApiError', got string starting with: <HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY> An e
at ServiceStack.Text.Common.DeserializeTypeRefJson.StringToType(Type type, String strType, EmptyCtorDelegate ctorFn, Dictionary`2 typeAccessorMap)
at ServiceStack.Text.JsonSerializer.DeserializeFromString[T](String value)
at MailChimp.MailChimpManager.MakeAPICall[T](String apiAction, Object args)
at ReQtest.Data.Commands.MailChimp.MailChimpApiFacade.<>c__DisplayClass12.<BatchSubscribeToList>b__e() in c:\TeamCity\buildAgent\work\5df5e08f77af18ac\src\WebApp\ReQtest.Data\Commands\MailChimp\MailChimpApiFacade.cs:line 96
at System.Threading.Tasks.Task`1.InvokeFuture(Object futureAsObj)
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants