Skip to content

gin.Error doesn't implement Unwrap method for non-pointers #4231

@OrkhanAlikhanov

Description

@OrkhanAlikhanov

I expect following code to print the wrapped error in both pointer and non-pointer uses. But it prints nil when you use it without pointer

package main

import (
	"errors"
	"fmt"

	"github.com/gin-gonic/gin"
)

func main() {
	err := gin.Error{Err: errors.New("test error")}
	fmt.Println(errors.Unwrap(err))  // prints nil
	fmt.Println(errors.Unwrap(&err)) // prints "test error" correctly
}

#631 removed pointer from Error() receiver to make gin.Error usable without pointer but the same change needs to be done for Unwrap() method as well

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions