Skip to content

Handle non-json errors #29

Closed
Closed

Description

@gufoe

Hello, I am getting the following error:
TypeError Cannot access offset of type string on string
from the file:
lib/ConvertApi/Client.php:156

This is because the server returns a non-json string.
This case should throw an Error\Api just like a json-error.
Just add this before using the $json as an array, on line 156:
if (is_string($json)) throw new Error\Api($json);

Activity

  1. linked a pull request that will close this issueHandle empty API response #36on Jun 26, 2022
  2. laurynas-convertapi commented on Jun 26, 2022

    @laurynas-convertapi
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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