mehdihadeli / go-food-delivery-microservices

🍕 A practical and imaginary food delivery microservices, built with golang, domain-driven design, cqrs, event sourcing, vertical slice architecture, event-driven architecture, and the latest technologies.
MIT License
873 stars 89 forks source link

Server crashes when a non existent route is called. #97

Open akashabbasi opened 7 months ago

akashabbasi commented 7 months ago

Server crashes when a non existent api is called on server. Error occurs in error parsing step. Specifically on below lines.

func ParseError(err error) ProblemDetailErr { stackTrace := errorUtils.ErrorsWithStack(err) customErr := customErrors.GetCustomError(err) var validatorErr validator.ValidationErrors

if err != nil {
    switch {
    case customErrors.IsDomainError(err, customErr.Status()):
        return NewDomainProblemDetail(customErr.Status(), customErr.Error(), stackTrace)

2nd line of function returns nil when we try to create custom error. and subsequent calls on nil causes panic which causes crash.

github-actions[bot] commented 7 months ago

Welcome to go-ecommerce-microservices. Thank you for reporting your first issue. Please check out our contributor guide.

mehdihadeli commented 7 months ago

Hi, Thanks for reporting, I probably missed that. I will fix it in the next release.