Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
histhub
dodis
Commits
5225ab8b
Commit
5225ab8b
authored
Oct 24, 2019
by
Tobinsk
Browse files
Merge branch '3-json-transform-error' into 'master'
Catch json transform error Closes
#3
See merge request
!4
parents
32f1f9b4
61fe6c81
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/dodis-normalizer-transformer.ts
View file @
5225ab8b
...
...
@@ -24,8 +24,8 @@ class DodisNormalizerTransformer extends Transform {
* @private
*/
public
_transform
(
chunk
,
encoding
,
callback
)
{
const
data
=
JSON
.
parse
(
chunk
.
res
.
body
);
try
{
const
data
=
JSON
.
parse
(
chunk
.
res
.
body
);
const
res
=
{
id
:
data
.
data
.
id
.
toString
(),
provider
:
'
dodis
'
,
...
...
@@ -39,6 +39,10 @@ class DodisNormalizerTransformer extends Transform {
return
callback
(
null
,
res
);
}
catch
(
error
)
{
if
(
error
.
name
===
'
SyntaxError
'
)
{
this
.
logger
.
warn
(
`Could not parse
${
chunk
.
url
}
`
);
return
callback
(
null
);
}
this
.
logger
.
error
(
error
);
return
callback
(
error
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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