GithubHelp home page GithubHelp logo

Not able to hide errors about stellar-php-sdk HOT 5 CLOSED

soneso avatar soneso commented on August 18, 2024
Not able to hide errors

from stellar-php-sdk.

Comments (5)

christian-rogobete avatar christian-rogobete commented on August 18, 2024 1

Hi @angelscry,

you are currently sending a https request to horizon to obtain the account data. As a result you receive the error message from Horizon that the account id is invalid.

Why don't you use only the KeyPair Class to check if the account id is valid. Like for example:

        $isValid = true;
        try {
            KeyPair::fromAccountId("GBEJWZEYDCJIKBW7PZKIJPRHD6WSPNETCEDV5UWRLDBLKXA7QT2DTLVF");
        } catch (Exception $e) {
            $isValid = false;
        }

By doing this you do not have to send data to Horizon to check if the account id is valid and there is no error message.

from stellar-php-sdk.

christian-rogobete avatar christian-rogobete commented on August 18, 2024

Hi @angelscry,

your account id is invalid, it has an invalid checksum.

You can see the same result if you use it in stellar laboratory

$kp = KeyPair::fromAccountId("GBEJWZEYDCJIKBW7PZKIJPRHD6WSPNETCEDV5UWRLDBLKXA7QT2DTLVF");

will also fail with:

InvalidArgumentException : invalid checksum in encoded data

from stellar-php-sdk.

angelscry avatar angelscry commented on August 18, 2024

Hi @christian-rogobete

Thank you for you quick reply. I think I expressed myself badly... Sorry...

Basically I want to test if an account id is valid or not by only using stellar-php-sdk. The account id into my script example is voluntarily wrong. As it is wrong, I want to be able to handle the corresponding error message. In my script I expected to only display :

Error: The request you sent was invalid in some way.

But it actually display :

{ "type": "https://stellar.org/horizon-errors/bad_request", "title": "Bad Request", "status": 400, "detail": "The request you sent was invalid in some way.", "extras": { "invalid_field": "account_id", "reason": "Account ID must start with G and contain 56 alphanum characters" } } Error: The request you sent was invalid in some way.

How to not have { "type": "https://stellar.org/horizon-errors/bad_request", "title": "Bad Request", "status": 400, "detail": "The request you sent was invalid in some way.", "extras": { "invalid_field": "account_id", "reason": "Account ID must start with G and contain 56 alphanum characters" } } displayed?

I have try to hide error messages and handle error messages, but it did not work. Or maybe I do something wrong...

from stellar-php-sdk.

angelscry avatar angelscry commented on August 18, 2024

Ho... That's effectively a more simple way to proceed.
Thank you.

from stellar-php-sdk.

christian-rogobete avatar christian-rogobete commented on August 18, 2024

yw

from stellar-php-sdk.

Related Issues (17)

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.