Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught network connection error #8

Closed
anton-khodak opened this issue Dec 7, 2018 · 2 comments
Closed

Uncaught network connection error #8

anton-khodak opened this issue Dec 7, 2018 · 2 comments
Assignees
Labels

Comments

@anton-khodak
Copy link

anton-khodak commented Dec 7, 2018

If a Postgres database is not available on the specified port/host, adapter panics with

panic: interface conversion: error is *net.OpError, not *pq.Error

goroutine 1 [running]:
github.com/cgpaas/casbin/vendor/github.com/casbin/xorm-adapter.(*Adapter).createDatabase(0xc000122000, 0x0, 0x0)
	/go/src/github.com/cgpaas/casbin/vendor/github.com/casbin/xorm-adapter/adapter.go:93 +0x30c
github.com/cgpaas/casbin/vendor/github.com/casbin/xorm-adapter.(*Adapter).open(0xc000122000)
	/go/src/github.com/cgpaas/casbin/vendor/github.com/casbin/xorm-adapter/adapter.go:113 +0xc6
github.com/cgpaas/casbin/vendor/github.com/casbin/xorm-adapter.NewAdapter(0x857f52, 0x8, 0xc0000f82d0, 0x47, 0x0, 0x0, 0x0, 0x850fc0)
	/go/src/github.com/cgpaas/casbin/vendor/github.com/casbin/xorm-adapter/adapter.go:69 +0x8f

There could be a handler for this case with a helpful error message

@hsluoyz hsluoyz closed this as completed in e40cbd1 Dec 7, 2018
@hsluoyz hsluoyz self-assigned this Dec 7, 2018
@hsluoyz hsluoyz added the bug label Dec 7, 2018
@anton-khodak
Copy link
Author

Thanks!

@hsluoyz
Copy link
Member

hsluoyz commented Dec 7, 2018

Thanks for the report. It has been fixed in: e40cbd1

Now it reports:

=== RUN   TestAdapters
2018/12/07 23:06:55 Policy: []
2018/12/07 23:06:55 Policy: [[alice data1 read] [bob data2 write] [data2_admin data2 read] [data2_admin data2 write]]
2018/12/07 23:06:55 Policy: [[alice data1 read] [bob data2 write] [data2_admin data2 read] [data2_admin data2 write]]
--- FAIL: TestAdapters (1.18s)
panic: dial tcp 127.0.0.1:5432: connectex: No connection could be made because the target machine actively refused it. [recovered]
	panic: dial tcp 127.0.0.1:5432: connectex: No connection could be made because the target machine actively refused it.

goroutine 19 [running]:
testing.tRunner.func1(0xc0000f2300)
	C:/Go/src/testing/testing.go:792 +0x38e
panic(0x7f0760, 0xc000154c30)
	C:/Go/src/runtime/panic.go:513 +0x1c7
github.com/casbin/xorm-adapter.(*Adapter).open(0xc0001d1890)
	C:/GoPath/src/github.com/casbin/xorm-adapter/adapter.go:114 +0x231
github.com/casbin/xorm-adapter.NewAdapter(0x848b91, 0x8, 0x85dad5, 0x36, 0x0, 0x0, 0x0, 0x7c2480)
	C:/GoPath/src/github.com/casbin/xorm-adapter/adapter.go:69 +0x96
github.com/casbin/xorm-adapter.initPolicy(0xc0000f2300, 0x848b91, 0x8, 0x85dad5, 0x36, 0x0, 0x0, 0x0)
	C:/GoPath/src/github.com/casbin/xorm-adapter/adapter_test.go:42 +0x101
github.com/casbin/xorm-adapter.testSaveLoad(0xc0000f2300, 0x848b91, 0x8, 0x85dad5, 0x36, 0x0, 0x0, 0x0)
	C:/GoPath/src/github.com/casbin/xorm-adapter/adapter_test.go:65 +0xa2
github.com/casbin/xorm-adapter.TestAdapters(0xc0000f2300)
	C:/GoPath/src/github.com/casbin/xorm-adapter/adapter_test.go:130 +0xba
testing.tRunner(0xc0000f2300, 0x862b28)
	C:/Go/src/testing/testing.go:827 +0xc6
created by testing.(*T).Run
	C:/Go/src/testing/testing.go:878 +0x35a

Process finished with exit code 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants