Giter Site home page Giter Site logo

Comments (1)

pkieltyka avatar pkieltyka commented on May 5, 2024

Good tip, I'll see about adding a nicer panic message, cuz it will still have to panic without an err check

On May 21, 2016, at 4:34 PM, Mgen [email protected] wrote:

I accidentally mounted an empty router, I didn't realise it, and it was hard to find out the problem due to the weird error message.

Code to reproduce this issue

package main

import (
"net/http"
"github.com/pressly/chi"
)

func main() {
r := chi.NewRouter()

apiRouter := chi.NewRouter()
r.Handle("/api", apiRouter)

http.ListenAndServe(":3000", r)

}
127.0.0.1:3000/abc: 404 page.
127.0.0.1:3000/api: panics.
127.0.0.1:3000/api/abc: panics.

Full error log:

2016/05/21 23:18:24 http: panic serving 127.0.0.1:49239: runtime error: invalid memory address or nil pointer dereference
goroutine 8 [running]:
net/http.(_conn).serve.func1(0xc82005e980)
/usr/local/Cellar/go/1.6/libexec/src/net/http/server.go:1389 +0xc1
panic(0x325240, 0xc82000a1a0)
/usr/local/Cellar/go/1.6/libexec/src/runtime/panic.go:426 +0x4e9
github.com/pressly/chi.(_Mux).ServeHTTPC(0xc8200125a0, 0x1a55910, 0xc820010cc0, 0x1a55858, 0xc8200f41a0, 0xc8200c2380)
/Users/Mgen/go/src/github.com/pressly/chi/mux.go:283 +0x648
github.com/pressly/chi.treeRouter.ServeHTTPC(0xc820014e40, 0x0, 0x1a55910, 0xc820010cc0, 0x1a55858, 0xc8200f41a0, 0xc8200c2380)
/Users/Mgen/go/src/github.com/pressly/chi/mux.go:352 +0x324
github.com/pressly/chi.(_treeRouter).ServeHTTPC(0xc82000af80, 0x1a55910, 0xc820010cc0, 0x1a55858, 0xc8200f41a0, 0xc8200c2380)
:18 +0xca
github.com/pressly/chi.(_Mux).ServeHTTPC(0xc820012550, 0x0, 0x0, 0x1a55858, 0xc8200f41a0, 0xc8200c2380)
/Users/Mgen/go/src/github.com/pressly/chi/mux.go:266 +0x112
github.com/pressly/chi.(_Mux).ServeHTTP(0xc820012550, 0x1a55858, 0xc8200f41a0, 0xc8200c2380)
/Users/Mgen/go/src/github.com/pressly/chi/mux.go:258 +0x4b
net/http.serverHandler.ServeHTTP(0xc82005e080, 0x1a55858, 0xc8200f41a0, 0xc8200c2380)
/usr/local/Cellar/go/1.6/libexec/src/net/http/server.go:2081 +0x19e
net/http.(_conn).serve(0xc82005e980)
/usr/local/Cellar/go/1.6/libexec/src/net/http/server.go:1472 +0xf2e
created by net/http.(*Server).Serve
/usr/local/Cellar/go/1.6/libexec/src/net/http/server.go:2137 +0x44e

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub

from chi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.