Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle StatusCode error better #4

Open
jsgoupil opened this issue Sep 2, 2015 · 1 comment
Open

Handle StatusCode error better #4

jsgoupil opened this issue Sep 2, 2015 · 1 comment

Comments

@jsgoupil
Copy link
Owner

jsgoupil commented Sep 2, 2015

Currently, in the ExecuteResponse we check if the main required object is present. But when there is an error, it ends up to be an ugly if case for each status error code.

Example with InvoiceAdd

if (response.InvoiceRet != null) { ... }
else if (response.statusCode == "3120") {

}

Not only this is ugly, but when the response is coming back with an error, there are no state saved properly with what has been sent and what is being returned.
So I end up doing either a save to the database or something ugly like:

                // If the object cannot be added, it's because the parent has been deleted.
                ////"Object "80000027-1429563689" specified in the request cannot be found.  QuickBooks error message: Invalid argument.  The specified record does not exist in the list."
                var startsWith = "Object \"";
                var endsWith = "\" specified in the request cannot be found.  QuickBooks error message: Invalid argument.  The specified record does not exist in the list.";
                if (response.statusMessage.StartsWith(startsWith) && response.statusMessage.EndsWith(endsWith))
                {
                    // We will remove the entity sync, we can't sync this invoice. We will also remove the site.
                    var invoiceIdStr = messageService.RetrieveMessage(authenticatedTicket.Ticket, GetName(), Key);
                    int invoiceId = 0;
                    if (invoiceIdStr != null && int.TryParse(invoiceIdStr, out invoiceId))
                    {
@mscappini
Copy link
Contributor

Do you think maybe we should make a new method that is called if the status code is not OK?

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

No branches or pull requests

2 participants