Coder Social home page Coder Social logo

Comments (4)

nategood avatar nategood commented on July 28, 2024

Why are you trying to json encode the Response object? There's probably a better way to do what you're trying to accomplish.

from httpful.

patrickyan avatar patrickyan commented on July 28, 2024

When an error occurs, I want to send an email with the entire response for alert + debugging purposes. JSON is a pretty format, so I thought of using it.

from httpful.

nategood avatar nategood commented on July 28, 2024

You definitely wouldn't want to json encode the whole PHP object then. I assume you mean the HTTP error? You can use $response->hasErrors() to check if there was an unsuccessful HTTP response and then the actual error itself would be in the body of the response. Might help if you post more context in a gist or something. This isn't a bug in Httpful though.

from httpful.

nategood avatar nategood commented on July 28, 2024

Looking back at this, the title and body of your issue imply two different things. If you are interesting in catching an exception and then JSON encoding it. I would recommend something like

json_encode(array(
  'error' => $e->getMessage()
));

Again more context and clarification here would be helpful.

from httpful.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.