Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
691fc331
Commit
691fc331
authored
Nov 23, 2017
by
Sietse Ringers
Browse files
Fix faulty panic catching during sessions
parent
db6535ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
irmaclient/client.go
View file @
691fc331
...
...
@@ -652,11 +652,11 @@ func (client *Client) unenrolledSchemeManagers() []irma.SchemeManagerIdentifier
func
(
client
*
Client
)
KeyshareEnroll
(
manager
irma
.
SchemeManagerIdentifier
,
email
,
pin
string
)
{
go
func
()
{
defer
func
()
{
handlePanic
(
func
(
err
*
irma
.
SessionError
)
{
if
e
:=
recover
();
e
!=
nil
{
if
client
.
handler
!=
nil
{
client
.
handler
.
EnrollmentError
(
manager
,
err
)
client
.
handler
.
EnrollmentError
(
manager
,
panicToError
(
e
)
)
}
}
)
}
}()
err
:=
client
.
keyshareEnrollWorker
(
manager
,
email
,
pin
)
...
...
irmaclient/irmaclient_test.go
View file @
691fc331
...
...
@@ -392,6 +392,7 @@ func TestWrongSchemeManager(t *testing.T) {
_
,
ok
:=
err
.
(
*
irma
.
SchemeManagerError
)
require
.
True
(
t
,
ok
)
require
.
Contains
(
t
,
client
.
Configuration
.
DisabledSchemeManagers
,
irmademo
)
require
.
NotContains
(
t
,
client
.
Configuration
.
SchemeManagers
,
irmademo
)
teardown
(
t
)
}
...
...
irmaclient/session.go
View file @
691fc331
...
...
@@ -152,11 +152,11 @@ func (client *Client) NewSession(qr *irma.Qr, handler Handler) SessionDismisser
// the request, and informs the user of the outcome.
func
(
session
*
session
)
start
()
{
defer
func
()
{
handlePanic
(
func
(
err
*
irma
.
SessionError
)
{
if
e
:=
recover
();
e
!=
nil
{
if
session
.
Handler
!=
nil
{
session
.
Handler
.
Failure
(
session
.
Action
,
err
)
session
.
Handler
.
Failure
(
session
.
Action
,
panicToError
(
e
)
)
}
}
)
}
}()
session
.
Handler
.
StatusUpdate
(
session
.
Action
,
irma
.
StatusCommunicating
)
...
...
@@ -255,11 +255,11 @@ func (session *session) start() {
func
(
session
*
session
)
do
(
proceed
bool
)
{
defer
func
()
{
handlePanic
(
func
(
err
*
irma
.
SessionError
)
{
if
e
:=
recover
();
e
!=
nil
{
if
session
.
Handler
!=
nil
{
session
.
Handler
.
Failure
(
session
.
Action
,
err
)
session
.
Handler
.
Failure
(
session
.
Action
,
panicToError
(
e
)
)
}
}
)
}
}()
if
!
proceed
{
...
...
@@ -388,11 +388,11 @@ func (session *session) sendResponse(message interface{}) {
func
(
session
*
session
)
managerSession
()
{
defer
func
()
{
handlePanic
(
func
(
err
*
irma
.
SessionError
)
{
if
e
:=
recover
();
e
!=
nil
{
if
session
.
Handler
!=
nil
{
session
.
Handler
.
Failure
(
session
.
Action
,
err
)
session
.
Handler
.
Failure
(
session
.
Action
,
panicToError
(
e
)
)
}
}
)
}
}()
// We have to download the scheme manager description.xml here before installing it,
...
...
@@ -432,23 +432,18 @@ func (session *session) managerSession() {
// Session lifetime functions
func
handlePanic
(
callback
func
(
*
irma
.
SessionError
))
{
if
e
:=
recover
();
e
!=
nil
{
var
info
string
switch
x
:=
e
.
(
type
)
{
case
string
:
info
=
x
case
error
:
info
=
x
.
Error
()
case
fmt
.
Stringer
:
info
=
x
.
String
()
default
:
// nop
}
fmt
.
Printf
(
"Recovered from panic: '%v'
\n
%s
\n
"
,
e
,
info
)
if
callback
!=
nil
{
callback
(
&
irma
.
SessionError
{
ErrorType
:
irma
.
ErrorPanic
,
Info
:
info
})
}
func
panicToError
(
e
interface
{})
*
irma
.
SessionError
{
var
info
string
switch
x
:=
e
.
(
type
)
{
case
string
:
info
=
x
case
error
:
info
=
x
.
Error
()
case
fmt
.
Stringer
:
info
=
x
.
String
()
default
:
// nop
}
return
&
irma
.
SessionError
{
ErrorType
:
irma
.
ErrorPanic
,
Info
:
info
}
}
// Idempotently send DELETE to remote server, returning whether or not we did something
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment