-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Implementing Render
for Result
#52
Comments
One of the problem is, should we support any In my opinion, template engines should avoid throwing unexpected error as much as possible, because they are mostly used in web applications, and developers must handle all errors raised during response. Good solution is implementing What do you think about this? Is there any use case for implementing |
Ideally, custom errors would be supported. That would give error handling code (within or outside
Because It's very common to use an error type like I see two advantages in supporting custom errors: (1) You can pass them back all the way to the original caller (like (2) To handle errors in parent template. This would be very useful in combination with my proposal for including templates. This means, for example, the calling template could:
For 1), for example, this could be including the error itself (the Rust error) into the HTML (which would be very useful while developing an app). Or showing an error message to the end-user ("Couldn't load widget X"). For 3), this could be a 404 error if, for example, an essential resource (that's selected using user input) isn't found. Or this could be a redirect to a different resource. At the moment, the only errors that can be returned are error strings, or I'm not sure, what the best way to implement my proposal would be. It seems, it would be possible to add a type parameter This would add the ability to It would probably be a breaking change, but I believe this would be very worth it. What do you think? |
Hi,
Another small improvement would be, implementing
Render
forResult
.Basically, if a result is
Ok(_)
, the value is extracted and rendered. And if there is an error, the template would fail with that error, similar to the?
operator in Rust.Would that be possible?
The text was updated successfully, but these errors were encountered: