Skip to content

[bugfix][xs] Text view when resource is missing fixed #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions routes/dms.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,12 @@ module.exports = function () {
// we can render as is in the template.
datapackage.displayResources = await Promise.all(datapackage.displayResources.map(async item => {
await Promise.all(item.resource.views.map(async (view, index) => {
if (view && view.specType === 'text' && item.resource.path) {
item.resource.views[index].content = await fetchTextContent(item.resource.path)
try {
if (view && view.specType === 'text' && item.resource.path) {
item.resource.views[index].content = await fetchTextContent(item.resource.path)
}
} catch(error) {
item.resource.views[index].content = 'There is no data for this view type'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gavram Maybe instead of content, sending it as errorMessage or failReason and then displaying it somehow different from a usual text view, so that it would be obvious to the user that this string is not the actual content, but an error warning?

Also, it's not certain here that there is no data, maybe there is data, but there was some other error that prevented from showing / fetching it. Maybe replacing it with something like 'Could not get data for this view'?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gavram I think saying "Could not get data for this view" is better as @EvgeniiaVak suggested. Could you change the message and we can get this PR merged?

}
}))
return item
Expand Down Expand Up @@ -229,6 +233,7 @@ module.exports = function () {
})
}).on('error', (e) => {
logger.error(e)
reject()
})
} else {
let buff = new Buffer(0)
Expand All @@ -245,6 +250,7 @@ module.exports = function () {
}
}).on('error', (e) => {
logger.error(e)
reject()
})
})
}
Expand Down