Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SPB_Exchange_Repo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Amelin Konstantin
SPB_Exchange_Repo
Commits
38c07285
Commit
38c07285
authored
Oct 26, 2018
by
Amelin Konstantin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add exception handler to Main.
parent
c617955d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
src/main/scala/Main.scala
+19
-3
src/main/scala/templates/Logger.scala
+0
-0
No files found.
src/main/scala/Main.scala
View file @
38c07285
...
...
@@ -37,10 +37,13 @@ object Main {
for
(
v
<-
Files
.
walk
(
Paths
.
get
(
args
(
0
))).
toArray
;
f
=
v
.
asInstanceOf
[
Path
];
if
!
Files
.
isDirectory
(
f
))
{
val
fSourceName
=
f
.
getFileName
.
toString
val
fOutputName
=
s
"Converted_$fSourceName"
val
now
=
LocalDateTime
.
now
().
toString
Try
{
val
sourceXml
=
XML
.
loadFile
(
f
.
toString
)
val
template
=
Template
(
sourceXml
)
val
outputXml
=
XML
.
loadString
(
p
.
format
(
template
.
render
))
val
now
=
LocalDateTime
.
now
().
toString
val
sourceXmlValid
=
if
(
template
.
isStraight
)
nsdXmlValid
else
rtsXmlValid
val
outputXmlValid
=
if
(
template
.
isStraight
)
rtsXmlValid
else
nsdXmlValid
...
...
@@ -61,10 +64,23 @@ object Main {
XML
.
save
(
Paths
.
get
(
args
(
1
),
fOutputName
).
toString
,
outputXml
,
xmlDecl
=
true
)
logString
+=
template
.
info
(
s
"$now\n$msgCheckSource\n$msgCheckOutput"
)
+
"\n\n"
template
.
info
(
s
"$now\n$msgCheckSource\n$msgCheckOutput"
)
+
"\n\n"
}
match
{
case
Success
(
ti
)
=>
logString
+=
ti
case
Failure
(
ex
)
=>
logString
+=
s
"'$now\nImpossible to convert'$fSourceName': ${ex.getMessage}\n\n"
}
}
Files
.
write
(
Paths
.
get
(
args
(
1
),
logFileName
),
logString
.
getBytes
(
"utf-8"
),
StandardOpenOption
.
CREATE
,
StandardOpenOption
.
TRUNCATE_EXISTING
)
Try
{
Files
.
write
(
Paths
.
get
(
args
(
1
),
logFileName
),
logString
.
getBytes
(
"utf-8"
),
StandardOpenOption
.
CREATE
,
StandardOpenOption
.
TRUNCATE_EXISTING
)
}
match
{
case
Success
(
_
)
=>
println
(
s
"Work has finished. $logFileName located in ${args(1)}"
)
case
Failure
(
ex
)
=>
println
(
s
"Error. Work hasn`t finished: ${ex.getMessage}"
)
}
}
}
}
src/main/scala/templates/Logger.scala
View file @
38c07285
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