|
|
|
|
|
by Wintamute
1985 days ago
|
|
I know this pattern and have used it myself. The problem is though, that generally you should only throw an error when you reach an exception - it's like saying "I don't know what to do next", and you defer that decision up the stack. Is a request that technically succeeds (the response has come back), but has a status code where the server has indicated something didn't work always an _exception_ in your client code? I'd argue it isn't, and should just be handled in the normal control flow of your client code via conditionals. |
|
Java users might want to make 404 an exception (FileNotFoundException), C++ users probably wouldn't throw an exception for that