LOD-Laundromat / lodlaundry.github.io

http://lodlaundromat.org
2 stars 2 forks source link

Beautify the exception status codes #33

Closed wouterbeek closed 10 years ago

wouterbeek commented 10 years ago

1

Make exceptions values for status easier to read. We already use the following code for this in the debug tools:

%! status_to_atom(+Term, -Atom) is det.

status_to_atom(literal(type(XsdString,Status1)), Status2):-
  rdf_equal(xsd:string, XsdString),
  read_term_from_atom(Status1, StatusTerm, []),
  once(status_to_atom0(StatusTerm, Status2)), !.
status_to_atom(Status, Status).

status_to_atom0(exception(error(existence_error(directory,_),_)), existence_error_directory).
status_to_atom0(exception(error(existence_error(source_sink,_),_)), existence_error_source_sink).
status_to_atom0(exception(error(http_status(Status),_)), Label):-
  atomic_list_concat([http_status,Status], '_', Label).
status_to_atom0(exception(error(instantiation_error(_),_)), instantiation_error).
status_to_atom0(exception(error(io_error(Mode,_),_)), Label):-
  atomic_list_concat([io_error,Mode], '_', Label).
status_to_atom0(exception(error(limit_exceeded(max_errors,_),_)), limit_exceeded_max_errors).
status_to_atom0(exception(error(no_rdf(_))), no_rdf).
status_to_atom0(exception(error(socket_error(_),_)), socket_error).
status_to_atom0(exception(error(ssl_error(Kind),_)), Label):-
  atomic_list_concat([ssl_error,Kind], '_', Label).
status_to_atom0(exception(error(timeout_error(Mode,_),_)), Label):-
  atomic_list_concat([timeout_error,Mode], '_', Label).
status_to_atom0(exception(error(type_error(xml_dom,_),_)), type_error_xml_dom).
status_to_atom0(false, false).
status_to_atom0(true, true).

2

Some values are slightly useless:

Property names are quite misleading: message / status -> warning / exception

Purpose: simplify SPARQL query writing and SPARQL result set reading.