Triply-Dev / YASGUI.YASR-deprecated

Deprecated, see https://github.com/TriplyDB/Yasgui for the Yasgui monorepo
MIT License
26 stars 22 forks source link

Improve exception reporting #7

Closed LaurensRietveld closed 9 years ago

LaurensRietveld commented 10 years ago

I'd like to use something like: yasqe.options.sparql.handlers.error = function(xhr, textStatus, errorThrown) { var exceptionMsg = textStatus + " (response status code " + xhr.status + ")"; if (errorThrown && errorThrown.length) exceptionMsg += ": " + errorThrown; if (xhr.responseText) exceptionMsg += "\nDetails: " + xhr.responseText; yasr.setResponse({exception: exceptionMsg}); }

But, because YASR only allows a single string exception, this gets formatted strangely. Make sure YASR supports passing both a string (only), but also an object with parameters: { statusCode, errorThrown, responseText } This way, we can format things more nicely

And, afterwards, update the glue gist

jneubert commented 9 years ago

An additional thing I observed: Currently, the string length seems to be limited, so with long queries the most interesting part of the message containing the actual error message of Fuseki`s parser is cut off.

LaurensRietveld commented 9 years ago

Is this endpoint currently up (and public)? Then I can test it on your fuseki instance ;)

jneubert commented 9 years ago

The endpoint is up and public: http://zbw.eu/beta/sparql/stwv/query, and I'm happy that I can provide a lenghty query just by linking :)

http://zbw.eu/beta/sparql-lab/?queryRef=https://api.github.com/repos/jneubert/skos-history/contents/sparql/stw/count_added_by_category.rq

jneubert commented 9 years ago

When I mess up the group by clause, this is what Fuseki provides in the log (and in the response, too):

09:48:38 INFO  [603] 400 Parse error:
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dsv: <http://purl.org/iso25964/DataSet/Versioning#>
PREFIX sd: <http://www.w3.org/ns/sparql-service-description#>
PREFIX sh: <http://purl.org/skos-history/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xhv: <http://www.w3.org/1999/xhtml/vocab#>
PREFIX zbwext: <http://zbw.eu/namespaces/zbw-extensions/>
#
# Identify concepts inserted with a certain version,
# ordered by the second level subject category.
# Subject categories have a different concept type (subclass of
# skos:Concept) and form mono-hierarchies within STW. The top
# level subject categories are the sub-thesauri. A descriptor
# often belongs to more than one subject category.
#
SELECT (str(count(?secondLevelLabel)) as ?countAddedConcepts) (max(?secondLevelConcept) as ?secondLevelCategory)
(str(?secondLevelLabel) AS ?secondLevelCategoryLabel)
WHERE {
  # parameters
  VALUES ( ?versionHistoryGraph ?language ) {
    ( <http://zbw.eu/stw/version> "en" )
  }
  GRAPH ?versionHistoryGraph {
    # use current version as default
    ?versionset dsv:currentVersionRecord ?currentVHR .
    ?currentVHR sh:hasDelta ?delta .
    ?currentVHR sh:usingNamedGraph/sd:name ?versionGraph .
    # get the delta to the previous version
    ?currentVHR xhv:prev ?previousVHR .
    ?delta sh:deltaTo ?currentVHR .
    ?delta sh:deltaFrom ?previousVHR .
    # identify insertions and deletions parts/graphs
    ?delta dcterms:hasPart ?insertions .
    ?insertions a sh:SchemeDeltaInsertions .
    ?insertions sh:usingNamedGraph/sd:name ?insertionsGraph .
    ?delta dcterms:hasPart ?deletions .
    ?deletions a sh:SchemeDeltaDeletions .
    ?deletions sh:usingNamedGraph/sd:name ?deletionsGraph .
  }
  # for each inserted concept, a (newly inserted) prefLabel must exist ...
  GRAPH ?insertionsGraph {
    ?concept skos:prefLabel ?prefLabel
  }
  # ... without any prefLabel deleted for this concept
  FILTER NOT EXISTS {
    GRAPH ?deletionsGraph {
      ?concept skos:prefLabel []
    }
  }
  GRAPH ?versionGraph {
    # get the top subject category (concept of subclass Thsys)
    # subject categories form a mono-hierarchy within STW
    ?concept skos:prefLabel ?prefLabel .
    ?concept skos:broader ?category .
    ?category a zbwext:Thsys .
    ?category skos:broader* ?topConcept .
    ?scheme skos:hasTopConcept ?topConcept .
    #
    # get the second level category
    ?topConcept skos:narrower ?secondLevelConcept .
    ?category skos:broader+ ?secondLevelConcept .
    #
    # get the label of the second level category
    ?secondLevelConcept skos:prefLabel ?secondLevelLabel
  }
  FILTER (lang(?prefLabel) = ?language && lang(?secondLevelLabel) = ?language)
}
GROUP BY ?secondLevelLabelx
ORDER BY ?secondLevelLabel ?prefLabel

Non-group key variable in SELECT: ?secondLevelLabel in expression str(?secondLevelLabel) (5 ms)
LaurensRietveld commented 9 years ago

ah, that response looks horrible indeed. I'll check how to best solve this. todo: enable two different parameters for the YASR exception handling.

LaurensRietveld commented 9 years ago

@jneubert this should be fixed now in new version (available later today/tomorrow). I've also made it easier to glue YASR and YASQE together (see this gist, which should work when the new YASR version is up: http://bl.ocks.org/LaurensRietveld/7d8beca5dbeb6b909b6f)

jneubert commented 9 years ago

Looks great now!

The diminishment of glue code is also a fine thing. Thanks!