Moving Error translation logic to the driver
Currently, the preview app checks for Connection Error on the container load path and based on status codes(401/403 or 404) decides that the error is AccessDenied or FileNotFound respectively.
This feels like it's something that belongs in the driver or some other common layer shared between the UI hosts because all the hosts will run into Connection Errors and we believe abstracting the hosts from the business of knowing what a particular Error type is and what 404 translates to is probably a better implementation. Rather the hosts should just get a signal that says 'hey this is FileNotFound error'
FYI @vladsud
Error definitions and interfaces are in error.ts
Currently IConnectionError is the one that just contains statusCode (like 400/401/403/404/500). The ask here is to break it into dedicated types (i.e. add to IError) and do translation in ODSP driver.
NetworkError is the only class that implements that interface. The only usage that matters goes through OdspNetworkError() class. Which maps to two usage cases:
- errorObjectFromOdspError()
- throwOdspNetworkError()
errorObjectFromOdspError() already essentially has a switch statement and created other types of error objects (FatalError, ThrottlingError) - this needs to be breaking out further for 404, 401/403.
throwOdspNetworkError() should probably call errorObjectFromOdspError() instead of creating OdspNetworkError directly.