Closed sixcorners closed 6 years ago
@sixcorners do you have an example where you see a gap? The service returns the error message string already e.g. please see this example.
What do you mean gap? That's a lot of code to write to read error messages and there are lots of exception types so I'm not even sure if I got them all. The exception type should either be constructed with message string or getMessage() should be overridden to return the exception information.
Most of these faults and exceptions are defined by the service e.g., AdApiFaultDetail for the Ad Insight service. For more details see Handling Service Errors and Exceptions. Are you asking for a custom SDK exception object that wraps all service exceptions?
If I don't have any special stuff I want to do for these different types of errors I would rather just work with the Exception base class. If all I want to do is print an error message usually I can use Throwable.getMessage() to get a string I can log, if there is additional details. That's what is usually expected of classes that extend Throwable.
It wouldn't have to be an exception that wraps exceptions. It could be a base class or something. I don't know much about how these types are generated. Is there a way to get this method implemented?
From the service definition (WSDL) each of the faults derive from ApplicationFault, which only contains a TrackingId. The contract for each can differ per the error handling guide. We can investigate options for abstracting these details. Even then, it might not make sense to return only one message. Each fault can include an array of errors per service call e.g. list of BatchError.
@sixcorners let's consider the example response below. There are multiple error codes, as well as duplicate instances of the same error code for different markets. These are returned directly from the service, and now the question is how should the client catch and parse the results via the SDK. The current implementation is flexible so that you can catch each service fault as previously discussed above.
We could add a new generic exception type e.g. "BingAdsServiceException" that you can catch, and then print out the full Xml SOAP string as shown below. Would that help? That said if you want to programmatically get details for each individual error, the current implementation would remain.
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:TrackingId xmlns:h="https://bingads.microsoft.com/CampaignManagement/v11">TrackingIdHere</h:TrackingId>
</s:Header>
<s:Body>
<AddKeywordsResponse xmlns="https://bingads.microsoft.com/CampaignManagement/v11">
<KeywordIds xmlns:a="http://schemas.datacontract.org/2004/07/System" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:long i:nil="true" />
<a:long>KeywordIdHere</a:long>
<a:long i:nil="true" />
</KeywordIds>
<PartialErrors xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>PH</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>NZ</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>MY</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>SG</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>GB</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>TH</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>VN</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>US</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>CA</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>AU</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>IE</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>FR</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>ID</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>IN</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError i:type="EditorialError">
<Code>1042</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceEditorialValidationError</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>0</Index>
<Message>The specified entity did not pass editorial validation. Please see the ReasonCode element of this error object for details.</Message>
<Type>EditorialError</Type>
<Appealable i:nil="true" />
<DisapprovedText>Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves Brand-A Gloves</DisapprovedText>
<Location>Keyword</Location>
<PublisherCountry>DE</PublisherCountry>
<ReasonCode>20001</ReasonCode>
</BatchError>
<BatchError>
<Code>1542</Code>
<Details i:nil="true" />
<ErrorCode>CampaignServiceKeywordAndMatchTypeCombinationAlreadyExists</ErrorCode>
<FieldPath i:nil="true" />
<ForwardCompatibilityMap i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Index>2</Index>
<Message>A keyword with the specified match type already exists.</Message>
<Type>BatchError</Type>
</BatchError>
</PartialErrors>
</AddKeywordsResponse>
</s:Body>
</s:Envelope>
Closing the ask due to low demand.
getMessage() should return a string representation of the reason the error message was thrown. Could the fault information each exception has be returned from this method?