You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having an error writer that returns an html page instead of what we do know is easy, would just require the html and css in which we then inject the error message/status code.
To make it dynamic based on the accept header we could link multiple error writers in a waterfall handler and have them check the preferences value in the canHandle function. This would require a change in the ResponseWriter interface since that doesn't accept RepresentationPreferences as input currently. Perhaps we could just add the entire Operation object as input in case they need to know something else.
RepresentationConverter takes as input a Representation and RepresentationPreferences (and an identifier), and outputs a new Representation based on the values found in both the metadata and the preferences.
ResponseWriter takes (for error response writers at least) an Error and an HttpResponse, and writes a representation of that error (currently just the stack trace) to the response. So to re-use the converters, we would first have to convert the error to a Representation, feed it into the converter mechanism and then pipe that to the response writer (this layer we already have). The only case where the middle converters would be useful is if a media type is requested for which we do not have an error->type converter. E.g., we have an ErrorToTurtle class but JSON-LD is requested. It's more overhead, but we could re-use the BasicResponseWriter also for errors then.
Is it really important to support error types in multiple media types though? I would think this is something where mostly the status code is important (and html in case something visual is needed), so having an html writer and the one we have now would be enough.
(At this point I'm even thinking, can't we just fully work API-based and let something else handle the html ;) )
we would first have to convert the error to a Representation
Why don't we turn the Error into a representation indeed? Let's say, a new internal type for errors?
The only case where the middle converters would be useful is if a media type is requested for which we do not have an error->type converter. E.g., we have an ErrorToTurtle class but JSON-LD is requested.
Exactly. All we need is ErrorToRdf, the rest we reuse.
Is it really important to support error types in multiple media types though?
Definitely already HTML and machine-readable, so yes.
can't we just fully work API-based and let something else handle the html
Good point, but resources (like images and video) can also be accessed directly.
Activity
jvherweg commentedon Mar 5, 2021
Having an error writer that returns an html page instead of what we do know is easy, would just require the html and css in which we then inject the error message/status code.
To make it dynamic based on the accept header we could link multiple error writers in a waterfall handler and have them check the preferences value in the
canHandlefunction. This would require a change in theResponseWriterinterface since that doesn't acceptRepresentationPreferencesas input currently. Perhaps we could just add the entireOperationobject as input in case they need to know something else.RubenVerborgh commentedon Mar 6, 2021
Can't we just entirely reuse the
RepresentationConvertormechanism? Such that future benefits like #484 can also be reused?jvherweg commentedon Mar 8, 2021
To re-use that we would need more layers though.
RepresentationConvertertakes as input aRepresentationandRepresentationPreferences(and an identifier), and outputs a newRepresentationbased on the values found in both the metadata and the preferences.ResponseWritertakes (for error response writers at least) anErrorand anHttpResponse, and writes a representation of that error (currently just the stack trace) to the response. So to re-use the converters, we would first have to convert the error to aRepresentation, feed it into the converter mechanism and then pipe that to the response writer (this layer we already have). The only case where the middle converters would be useful is if a media type is requested for which we do not have an error->type converter. E.g., we have anErrorToTurtleclass but JSON-LD is requested. It's more overhead, but we could re-use theBasicResponseWriteralso for errors then.Is it really important to support error types in multiple media types though? I would think this is something where mostly the status code is important (and html in case something visual is needed), so having an html writer and the one we have now would be enough.
(At this point I'm even thinking, can't we just fully work API-based and let something else handle the html ;) )
RubenVerborgh commentedon Mar 10, 2021
Why don't we turn the
Errorinto a representation indeed? Let's say, a new internal type for errors?Exactly. All we need is
ErrorToRdf, the rest we reuse.Definitely already HTML and machine-readable, so yes.
Good point, but resources (like images and video) can also be accessed directly.