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
61fe6c81
Commit
61fe6c81
authored
Oct 24, 2019
by
Tobinsk
Browse files
Catch json transform error
parent
32f1f9b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/dodis-normalizer-transformer.ts
View file @
61fe6c81
...
...
@@ -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