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
bonita
bonita-ui-designer-sdk
Commits
74baa2f7
Commit
74baa2f7
authored
Apr 07, 2021
by
Jerome Cambon
Browse files
Better error handling
parent
e00a6c8d
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
custom-widget-builder/package-lock.json
View file @
74baa2f7
This diff is collapsed.
Click to expand it.
custom-widget-builder/src/CustomTagHandler.ts
View file @
74baa2f7
...
...
@@ -93,7 +93,7 @@ export class CustomTagHandler {
this
.
showFor
=
tagValue
;
break
;
default
:
console
.
log
(
`Error: invalid tag:
${
tagName
}
`
);
console
.
error
(
`Error: invalid tag:
${
tagName
}
`
);
}
}
...
...
custom-widget-builder/src/CustomWidgetBuilder.ts
View file @
74baa2f7
...
...
@@ -31,12 +31,23 @@ export class CustomWidgetBuilder {
public
generatePropertiesFile
(
wcFile
:
string
,
outputDir
:
string
)
{
this
.
wcFile
=
wcFile
;
this
.
outputDir
=
outputDir
;
this
.
createPropertiesFile
(
this
.
getPropertiesInfo
());
if
(
!
fs
.
existsSync
(
this
.
outputDir
))
{
console
.
error
(
`Output directory does not exist:
${
this
.
outputDir
}
`
);
return
;
}
try
{
this
.
createPropertiesFile
(
this
.
getPropertiesInfo
());
}
catch
(
e
)
{
console
.
error
(
e
.
message
);
}
}
private
getPropertiesInfo
():
PropertiesInfo
{
let
info
=
JSON
.
parse
(
this
.
analyzeFile
()).
tags
[
0
];
let
analyzeResult
=
this
.
analyzeFile
();
if
(
!
analyzeResult
)
{
throw
new
Error
(
`No properties found in file:
${
this
.
wcFile
}
`
);
}
let
info
=
JSON
.
parse
(
analyzeResult
).
tags
[
0
];
if
(
!
info
)
{
throw
new
Error
(
`Cannot get any information from file
${
this
.
wcFile
}
\nExiting...`
);
}
...
...
@@ -54,19 +65,16 @@ export class CustomWidgetBuilder {
}
private
createPropertiesFile
(
propertiesInfo
:
PropertiesInfo
)
{
//TODO replace console.log() by logging
let
output
=
JSON
.
stringify
(
propertiesInfo
,
null
,
2
)
// console.log(output);
if
(
!
fs
.
existsSync
(
this
.
outputDir
))
{
console
.
log
(
`ERROR: output directory does not exist:
${
this
.
outputDir
}
`
);
return
;
}
let
filePath
=
`
${
this
.
outputDir
}
/
${
propertiesInfo
.
id
}
.json`
;
fs
.
writeFileSync
(
filePath
,
output
);
console
.
log
(
`
${
filePath
}
has been generated!`
);
}
private
analyzeFile
():
string
{
if
(
!
fs
.
existsSync
(
this
.
wcFile
))
{
throw
new
Error
(
`File does not exist:
${
this
.
wcFile
}
`
);
}
let
fileStr
=
fs
.
readFileSync
(
this
.
wcFile
,
"
utf8
"
).
toString
();
let
result
:
AnalyzeTextResult
=
analyzeText
(
fileStr
);
return
transformAnalyzerResult
(
"
json
"
,
result
.
results
,
result
.
program
,
{
visibility
:
"
public
"
});
...
...
Write
Preview
Markdown
is supported
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