• Echo Dot
    link
    fedilink
    arrow-up
    63
    arrow-down
    3
    ·
    edit-2
    4 days ago

    What programming language returns a 500 error because it fails?

    A 500 error code is a critical server failure, It isn’t something that can happen because a piece of JavaScript failed.

    • sugar_in_your_tea@sh.itjust.works
      link
      fedilink
      arrow-up
      11
      ·
      3 days ago

      Javascript also exists on the server, and an exception would cause a 500 error. Semicolons are optional in JavaScript, except for a handful of cases. One of those is in a for loop. I’m guessing the professor was running a nodejs app and did something like this (intentionally bad style because professor):

      for (x = 0; x < 5 x++)
      {} 
      return x
      

      Boom, syntax error, which would return a 500 air status in a nodejs web server framework.

    • KubeRoot@discuss.tchncs.de
      link
      fedilink
      English
      arrow-up
      36
      ·
      4 days ago

      Maybe PHP? Since it runs as a server and returns computed results in a browser… Though I’m pretty sure it’d just return the compiler error text

      • Echo Dot
        link
        fedilink
        arrow-up
        13
        arrow-down
        2
        ·
        4 days ago

        Php outputs HTML at the end of the process. If it didn’t run because of a missing semicolon it would just output an error. It wouldn’t crash

        • lurch (he/him)@sh.itjust.works
          link
          fedilink
          arrow-up
          5
          ·
          3 days ago

          this is not always true. many tutorials encourage people to do a setup that does not output a PHP error to the web, as it can leak info that may help an attacker, such as the file path the error occurred in. in setups like these PHP will log the error to a file an attacker can’t access (often /var/log/php/error.log ) and exit with a failure status code, which many common web server setups will turn into an HTTP 500 error. Some server setups will just send an empty file though, which will be a blank white page shown in a browser.

    • ඞmir@lemmy.ml
      link
      fedilink
      arrow-up
      12
      ·
      4 days ago

      Old IIS versions with PHP would do this when running in production mode. Talking about 2010-2012

    • merc@sh.itjust.works
      link
      fedilink
      arrow-up
      17
      ·
      4 days ago

      Any programming language that runs on the web server and doesn’t gracefully handle its errors. There are many web servers implemented in Javascript, but it could also be Java, it could be Perl, it could even be C/C++ if someone is being masochistic.