• arendjr@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    13 days ago

    Well, looking at your example, I think a good case can even be made for it.

    “s23” doesn’t look like an HTTP status code, so including it can make total sense. After all, there’s plenty of reasons why you could want custom error codes that don’t really align with HTTP codes, and customised error messages are also a sensible use case for that.

    Of course duplicating the actual HTTP status code in your body is just silly. And if you use custom error codes, it often still makes sense to use the closest matching HTTP status code in addition to it (so yeah, I agree the 200 in your example doesn’t make a lot of sense). But neither of those preclude good reasons for custom codes.

    • Opisek@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      13 days ago

      Still, 200 should not be returned. If you have your own codes, just return 500 alongside that custom code.