@@ -61,33 +61,21 @@ impl AppStateError {
6161/// Global error page generated from an [AppStateError].
6262#[ derive( Debug , Template , WebTemplate ) ]
6363#[ template( path = "error.html" ) ]
64- pub struct AppStateErrorContext {
65- state : AppStateErrorContextInner ,
66- }
67-
68- /// Helper struct so we can reuse base.html
69- /// with all it's `state.foo` expressions.
70- #[ derive( Debug ) ]
71- pub struct AppStateErrorContextInner {
72- // TODO: askama doesn't handle recursion well, so we convert
73- // all errors to strings. Maybe related to:
74- // https://github.com/askama-rs/askama/issues/393
64+ pub struct AppStateErrorTemplate {
7565 errors : Vec < AppStateError > ,
7666}
7767
78- impl From < AppStateError > for AppStateErrorContext {
68+ impl From < AppStateError > for AppStateErrorTemplate {
7969 fn from ( e : AppStateError ) -> Self {
8070 // An error is being displayed to the user, make sure it's also written in the logs
8171 e. log ( ) ;
82- Self {
83- state : AppStateErrorContextInner { errors : vec ! [ e] } ,
84- }
72+ Self { errors : vec ! [ e] }
8573 }
8674}
8775
8876impl IntoResponse for AppStateError {
8977 fn into_response ( self ) -> Response {
90- let error_context = AppStateErrorContext :: from ( self ) ;
78+ let error_context = AppStateErrorTemplate :: from ( self ) ;
9179 ( StatusCode :: INTERNAL_SERVER_ERROR , error_context) . into_response ( )
9280 }
9381}
0 commit comments