github.com/blend/go-sdk@v1.20220411.3/web/logged_error_result.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package web 9 10 // ResultWithLoggedError logs an error before it renders the result. 11 func ResultWithLoggedError(result Result, err error) *LoggedErrorResult { 12 return &LoggedErrorResult{ 13 Error: err, 14 Result: result, 15 } 16 } 17 18 var ( 19 _ Result = (*LoggedErrorResult)(nil) 20 _ ResultPostRender = (*LoggedErrorResult)(nil) 21 ) 22 23 // LoggedErrorResult is a result that returns an error during the prerender phase. 24 type LoggedErrorResult struct { 25 Result Result 26 Error error 27 } 28 29 // Render renders the result. 30 func (ler LoggedErrorResult) Render(ctx *Ctx) error { 31 return ler.Result.Render(ctx) 32 } 33 34 // PostRender returns the underlying error. 35 func (ler LoggedErrorResult) PostRender(ctx *Ctx) error { 36 return ler.Error 37 }