Skip to content

Improve FAPI error handling #50

@dimitrystd

Description

@dimitrystd

Tried to upload file, but FAPI returned error. As result i got error in SDK instead of the original error

Response code: 0 
Response message: Bad response format from Smartling 
Response trace: #0 /usr/share/nginx/dreamtrips/vendor/smartling/api-sdk-php/src/BaseApiAbstract.php(321): Smartling\BaseApiAbstract->processError(Object(GuzzleHttp\Message\Response)) 
#1 /usr/share/nginx/dreamtrips/vendor/smartling/api-sdk-php/src/BaseApiAbstract.php(500): Smartling\BaseApiAbstract->processErrors(Object(GuzzleHttp\Message\Response)) 
#2 /usr/share/nginx/dreamtrips/vendor/smartling/api-sdk-php/src/File/FileApi.php(82): Smartling\BaseApiAbstract->sendRequest('file', Array, 'post') 
#3 /usr/share/nginx/dreamtrips/app/Services/Translator/SmartlingApi.php(82): Smartling\File\FileApi->uploadFile('data://text/pla...', 'errors.json', 'json')

FAPI error was

{
  "response": {
    "code": "GENERAL_ERROR",
    "messages": [
      "An error has occurred and administrators have been notified. For more information, please contact <a href=\"mailto:support@smartling.com\">support@smartling.com</a> with reference code \"j5meo4yt\"."
    ],
    "data": null
  }
}

DoD:

  • SDK can handle not only sussess FAPI responses buy error responses too
  • Cover this case with unit test

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions