Reputation: 6598
I have a functionality that upload a file, validate it, save it to database and so on.
All of these actions are on some different classes and methods. But, if something goes wrong in any of these methods, I want to inform these errors to my front-end.
Is there a good way to manage this, let's call, "Error Class"?
Thanks!
Upvotes: 1
Views: 225
Reputation: 1919
Well lets say, your sequence of processing a file is
Now, in all these sequence if its same all the time, then you could just go for exception throwing mechanism and collect it at the front end. May be you could throw with an Error ID.
Upvotes: 0
Reputation: 674
One approach that you could take would be to create the "Error Class" like a service in your application and post the different classes and methods that perform various actions could post errors to it.
Now your front-end can either subscribe with the "Error Class" to know of errors immediately or you could return an error code the details of which can be found using the "Error Class"
Upvotes: 1