Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
8818cb65
Unverified
Commit
8818cb65
authored
May 15, 2019
by
chicm-ms
Committed by
GitHub
May 15, 2019
Browse files
Handle string type error (#1064)
parent
34988d9b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
9 deletions
+26
-9
src/nni_manager/common/errors.ts
src/nni_manager/common/errors.ts
+17
-0
src/nni_manager/core/ipcInterface.ts
src/nni_manager/core/ipcInterface.ts
+1
-1
src/nni_manager/core/nniDataStore.ts
src/nni_manager/core/nniDataStore.ts
+3
-3
src/nni_manager/core/nnimanager.ts
src/nni_manager/core/nnimanager.ts
+5
-5
No files found.
src/nni_manager/common/errors.ts
View file @
8818cb65
...
@@ -35,6 +35,23 @@ export class NNIError extends Error {
...
@@ -35,6 +35,23 @@ export class NNIError extends Error {
}
}
this
.
cause
=
err
;
this
.
cause
=
err
;
}
}
public
static
FromError
(
err
:
NNIError
|
Error
|
string
,
messagePrefix
?:
string
):
NNIError
{
const
msgPrefix
:
string
=
messagePrefix
===
undefined
?
''
:
messagePrefix
;
if
(
err
instanceof
NNIError
)
{
if
(
err
.
message
!==
undefined
)
{
err
.
message
=
msgPrefix
+
err
.
message
;
}
return
err
;
}
else
if
(
typeof
(
err
)
===
'
string
'
)
{
return
new
NNIError
(
''
,
msgPrefix
+
err
);
}
else
if
(
err
instanceof
Error
)
{
return
new
NNIError
(
''
,
msgPrefix
+
err
.
message
,
err
);
}
else
{
throw
new
Error
(
`Wrong instance type:
${
typeof
(
err
)}
`
);
}
}
}
}
export
class
MethodNotImplementedError
extends
Error
{
export
class
MethodNotImplementedError
extends
Error
{
...
...
src/nni_manager/core/ipcInterface.ts
View file @
8818cb65
...
@@ -106,7 +106,7 @@ class IpcInterface {
...
@@ -106,7 +106,7 @@ class IpcInterface {
this
.
logger
.
warning
(
'
Commands jammed in buffer!
'
);
this
.
logger
.
warning
(
'
Commands jammed in buffer!
'
);
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
throw
new
NNIError
(
'
Dispatcher
Error
'
,
`
Dispatcher Error:
${
err
.
message
}
`
,
err
);
throw
NNIError
.
From
Error
(
err
,
'
Dispatcher Error:
'
);
}
}
}
}
...
...
src/nni_manager/core/nniDataStore.ts
View file @
8818cb65
...
@@ -77,7 +77,7 @@ class NNIDataStore implements DataStore {
...
@@ -77,7 +77,7 @@ class NNIDataStore implements DataStore {
try
{
try
{
await
this
.
db
.
storeExperimentProfile
(
experimentProfile
);
await
this
.
db
.
storeExperimentProfile
(
experimentProfile
);
}
catch
(
err
)
{
}
catch
(
err
)
{
throw
new
NNIError
(
'
Datastore error
'
,
`
Datastore error:
${
err
.
message
}
`
,
err
);
throw
NNIError
.
FromError
(
err
,
'
Datastore error:
'
);
}
}
}
}
...
@@ -105,7 +105,7 @@ class NNIDataStore implements DataStore {
...
@@ -105,7 +105,7 @@ class NNIDataStore implements DataStore {
return
this
.
db
.
storeTrialJobEvent
(
event
,
trialJobId
,
timestamp
,
hyperParameter
,
jobDetail
).
catch
(
return
this
.
db
.
storeTrialJobEvent
(
event
,
trialJobId
,
timestamp
,
hyperParameter
,
jobDetail
).
catch
(
(
err
:
Error
)
=>
{
(
err
:
Error
)
=>
{
throw
new
NNIError
(
'
Datastore error
'
,
`
Datastore error:
${
err
.
message
}
`
,
err
);
throw
NNIError
.
FromError
(
err
,
'
Datastore error:
'
);
}
}
);
);
}
}
...
@@ -163,7 +163,7 @@ class NNIDataStore implements DataStore {
...
@@ -163,7 +163,7 @@ class NNIDataStore implements DataStore {
timestamp
:
Date
.
now
()
timestamp
:
Date
.
now
()
}));
}));
}
catch
(
err
)
{
}
catch
(
err
)
{
throw
new
NNIError
(
'
Datastore error
'
,
`
Datastore error
:
${
err
.
message
}
`
,
err
);
throw
NNIError
.
FromError
(
err
,
'
Datastore error
'
);
}
}
}
}
...
...
src/nni_manager/core/nnimanager.ts
View file @
8818cb65
...
@@ -573,13 +573,13 @@ class NNIManager implements Manager {
...
@@ -573,13 +573,13 @@ class NNIManager implements Manager {
await
Promise
.
all
([
await
Promise
.
all
([
this
.
periodicallyUpdateExecDuration
(),
this
.
periodicallyUpdateExecDuration
(),
this
.
pingDispatcher
().
catch
((
err
:
Error
)
=>
{
this
.
pingDispatcher
().
catch
((
err
:
Error
)
=>
{
throw
new
NNIError
(
'
Dispatcher error
'
,
`
Dispatcher error:
${
err
.
message
}
`
,
err
);
throw
NNIError
.
FromError
(
err
,
'
Dispatcher error:
'
);
}),
}),
this
.
trainingService
.
run
().
catch
((
err
:
Error
)
=>
{
this
.
trainingService
.
run
().
catch
((
err
:
Error
)
=>
{
throw
new
NNIError
(
'
Training service error
'
,
`
Training service error:
${
err
.
message
}
`
,
err
);
throw
NNIError
.
FromError
(
err
,
'
Training service error:
'
);
}),
}),
this
.
manageTrials
().
catch
((
err
:
Error
)
=>
{
this
.
manageTrials
().
catch
((
err
:
Error
)
=>
{
throw
new
NNIError
(
'
Job management error
'
,
`
Job management error:
${
err
.
message
}
`
,
err
);
throw
NNIError
.
FromError
(
err
,
'
Job management error:
'
);
})]);
})]);
}
}
...
@@ -591,13 +591,13 @@ class NNIManager implements Manager {
...
@@ -591,13 +591,13 @@ class NNIManager implements Manager {
}
}
this
.
trainingService
.
addTrialJobMetricListener
((
metric
:
TrialJobMetric
)
=>
{
this
.
trainingService
.
addTrialJobMetricListener
((
metric
:
TrialJobMetric
)
=>
{
this
.
onTrialJobMetrics
(
metric
).
catch
((
err
:
Error
)
=>
{
this
.
onTrialJobMetrics
(
metric
).
catch
((
err
:
Error
)
=>
{
this
.
criticalError
(
new
NNIError
(
'
Job metrics error
'
,
`
Job metrics error:
${
err
.
message
}
`
,
err
));
this
.
criticalError
(
NNIError
.
FromError
(
err
,
'
Job metrics error:
'
));
});
});
});
});
this
.
dispatcher
.
onCommand
((
commandType
:
string
,
content
:
string
)
=>
{
this
.
dispatcher
.
onCommand
((
commandType
:
string
,
content
:
string
)
=>
{
this
.
onTunerCommand
(
commandType
,
content
).
catch
((
err
:
Error
)
=>
{
this
.
onTunerCommand
(
commandType
,
content
).
catch
((
err
:
Error
)
=>
{
this
.
criticalError
(
new
NNIError
(
'
Tuner command event error
'
,
`
Tuner command event error:
${
err
.
message
}
`
,
err
));
this
.
criticalError
(
NNIError
.
FromError
(
err
,
'
Tuner command event error:
'
));
});
});
});
});
}
}
...
...
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