Coder Social home page Coder Social logo

TypeError if no trips were found about ns-api HOT 7 CLOSED

aquatix avatar aquatix commented on August 15, 2024
TypeError if no trips were found

from ns-api.

Comments (7)

aquatix avatar aquatix commented on August 15, 2024

Good one. Currently it catches the error from the NS XML API and prints "Error in trips: Geen geldige 'fromStation' opgegeven", returning None (as the input is 'faulty'), but I guess an empty list would work just as well. Going to change that now and push a new version.

Thanks!

from ns-api.

bartromgens avatar bartromgens commented on August 15, 2024

The input is valid in this case, meaning that the fromStation is in the list of stations given by nsapi.

Your fix does not resolve the problem. 'error' in obj is False so it moves on to for trip in obj['ReisMogelijkheden']['ReisMogelijkheid'] and then raises a TypeError exception. That is at least what happens for me.

I am fine with None or empty list as return from get_trips. Just not a TypeError exception.

from ns-api.

aquatix avatar aquatix commented on August 15, 2024

Oh my bad, I copied your example and there's "Utrecht Central" in there (mind the single 'a'), so I got a different error. Apparantly I need more coffee, as your issue is with something else entirely. Just reproduced, going to fix now.

from ns-api.

bartromgens avatar bartromgens commented on August 15, 2024

Ah, my bad as well. Typo in the example that reproduces the error :) Sorry. Thanks for looking into it.

from ns-api.

aquatix avatar aquatix commented on August 15, 2024

No worries :) Shall I return None in both cases, or an empty list? I prefer None, as that shows that something went wrong.

from ns-api.

bartromgens avatar bartromgens commented on August 15, 2024

Yes, I also prefer None.

from ns-api.

bartromgens avatar bartromgens commented on August 15, 2024

Great. Thanks!

from ns-api.

Related Issues (19)

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.