Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
77bda6bf
Commit
77bda6bf
authored
6 years ago
by
Julia Friesel
Browse files
Options
Downloads
Patches
Plain Diff
Make import errors prettier and actually handle them
parent
44cc4482
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/settings.js
+11
-8
11 additions, 8 deletions
components/settings.js
lib/import-export/import-from-csv.js
+4
-10
4 additions, 10 deletions
lib/import-export/import-from-csv.js
with
15 additions
and
18 deletions
components/settings.js
+
11
−
8
View file @
77bda6bf
...
@@ -42,11 +42,11 @@ async function openShareDialogAndExport() {
...
@@ -42,11 +42,11 @@ async function openShareDialogAndExport() {
try
{
try
{
data
=
getDataAsCsvDataUri
()
data
=
getDataAsCsvDataUri
()
if
(
!
data
)
{
if
(
!
data
)
{
return
A
lert
.
alert
(
labels
.
errors
.
noData
)
return
a
lert
Error
(
labels
.
errors
.
noData
)
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
err
)
console
.
error
(
err
)
return
A
lert
.
alert
(
labels
.
errors
.
couldNotConvert
)
return
a
lert
Error
(
labels
.
errors
.
couldNotConvert
)
}
}
try
{
try
{
...
@@ -59,7 +59,7 @@ async function openShareDialogAndExport() {
...
@@ -59,7 +59,7 @@ async function openShareDialogAndExport() {
})
})
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
err
)
console
.
error
(
err
)
return
A
lert
.
alert
(
labels
.
errors
.
problemSharing
)
return
a
lert
Error
(
labels
.
errors
.
problemSharing
)
}
}
}
}
...
@@ -83,14 +83,17 @@ async function getFileContentAndImport() {
...
@@ -83,14 +83,17 @@ async function getFileContentAndImport() {
try
{
try
{
fileContent
=
await
rnfs
.
readFile
(
fileInfo
.
uri
,
'
utf8
'
)
fileContent
=
await
rnfs
.
readFile
(
fileInfo
.
uri
,
'
utf8
'
)
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
)
return
alertError
(
'
Could not open file
'
)
return
Alert
.
alert
(
'
Could not open file
'
)
}
}
try
{
try
{
importCsv
(
fileContent
,
false
)
await
importCsv
(
fileContent
,
false
)
Alert
.
alert
(
'
Data successfully imported
'
)
Alert
.
alert
(
'
Success
'
,
'
Data successfully imported
'
)
}
catch
(
err
)
{
}
catch
(
err
)
{
//TODO
alertError
(
err
.
message
)
}
}
}
}
function
alertError
(
msg
)
{
Alert
.
alert
(
'
Error
'
,
msg
)
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/import-export/import-from-csv.js
+
4
−
10
View file @
77bda6bf
...
@@ -37,15 +37,9 @@ export default async function importCsv(csv, deleteFirst) {
...
@@ -37,15 +37,9 @@ export default async function importCsv(csv, deleteFirst) {
},
{})
},
{})
}
}
let
cycleDays
const
cycleDays
=
await
csvParser
(
config
)
try
{
.
fromString
(
csv
)
cycleDays
=
await
csvParser
(
config
)
.
on
(
'
header
'
,
validateHeaders
)
.
fromString
(
csv
)
.
on
(
'
header
'
,
validateHeaders
)
}
catch
(
err
)
{
// TODO
console
.
log
(
err
)
}
//remove symptoms where all fields are null
//remove symptoms where all fields are null
putNullForEmptySymptoms
(
cycleDays
)
putNullForEmptySymptoms
(
cycleDays
)
...
@@ -72,7 +66,7 @@ function tryToCreateCycleDay(day, i) {
...
@@ -72,7 +66,7 @@ function tryToCreateCycleDay(day, i) {
try
{
try
{
db
.
create
(
'
CycleDay
'
,
day
)
db
.
create
(
'
CycleDay
'
,
day
)
}
catch
(
err
)
{
}
catch
(
err
)
{
const
msg
=
`
Error for l
ine
${
i
+
1
}
(
${
day
.
date
}
):
${
err
.
message
}
`
const
msg
=
`
L
ine
${
i
+
1
}
(
${
day
.
date
}
):
${
err
.
message
}
`
throw
new
Error
(
msg
)
throw
new
Error
(
msg
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment