JSON ERROR MESSAGE for catch exceptions.
- Parameters
-
- Returns
- error message JSON
54 Gson gson =
new GsonBuilder().setPrettyPrinting().create();
55 JSONObject jsonobj_error =
new JSONObject();
56 JSONObject jsonobj_error_data =
new JSONObject();
57 JSONArray jsonarray_element =
new JSONArray();
58 for (StackTraceElement element : exception.getStackTrace()) {
59 JSONObject errMessage =
new JSONObject();
60 errMessage.put(
"class", element.getClassName());
61 errMessage.put(
"method", element.getMethodName());
62 errMessage.put(
"line", element.getLineNumber());
63 jsonarray_element.add(errMessage);
65 if (element.getClassName().equals(endClass)) {
71 String userMessage =
"";
72 if (exception.toString().contains(
"NullPointerException")) {
74 userMessage =
"some value is not available";
75 }
else if (exception.toString().contains(
"ValidateJSONObjectException")) {
77 String[] ex = exception.toString().split(
": ");
78 userMessage =
"validate JSON object exception: " + ex[1];
81 jsonobj_error.put(
"errors", jsonobj_error_data);
82 jsonobj_error_data.put(
"internalMessage", exception.toString());
83 jsonobj_error_data.put(
"userMessage", userMessage);
84 jsonobj_error_data.put(
"code", code);
85 jsonobj_error_data.put(
"developerInfo", jsonarray_element);
87 return gson.toJson(jsonobj_error);
Referenced by ImportcsvResource.csvUpload(), ImportcsvResource.csvUploadDirectResponse(), ImportcsvResource.csvUploadUpdate(), AgentsResource.deleteAgent(), LabelsResource.deleteLabel(), VocabsResource.deleteVocabulary(), AgentsResource.getAgent(), AgentsResource.getAgent_JSON(), AgentsResource.getAgent_XML(), AgentsResource.getAgentRDF_JSONLD(), AgentsResource.getAgentRDF_JSONRDF(), AgentsResource.getAgentRDF_N3(), AgentsResource.getAgentRDF_Turtle(), AgentsResource.getAgentRDF_XML(), AgentsResource.getAgents(), RestResource.getAPIpage(), InfoResource.getAPIpage(), DumpResource.getDump(), AuthResource.getHash(), RetcatResource.getInfoArchwort(), RetcatResource.getInfoBGS(), RetcatResource.getInfoChronontology(), RetcatResource.getInfoDBpedia(), RetcatResource.getInfoExtern(), RetcatResource.getInfoGeoNames(), RetcatResource.getInfoGetty(), RetcatResource.getInfoHeritageData(), RetcatResource.getInfoLabelingSystem(), RetcatResource.getInfoPelagios(), RetcatResource.getInfoPersonDB(), RetcatResource.getInfoSkosmosFao(), RetcatResource.getInfoSkosmosFinto(), RetcatResource.getInfoSkosmosUnesco(), RetcatResource.getInfoWikidata(), LabelsResource.getLabel(), LabelsResource.getLabel_BNR(), LabelsResource.getLabel_JSON(), LabelsResource.getLabel_Relations(), LabelsResource.getLabel_XML(), LabelsResource.getLabelRDF_JSONLD(), LabelsResource.getLabelRDF_JSONRDF(), LabelsResource.getLabelRDF_N3(), LabelsResource.getLabelRDF_Turtle(), LabelsResource.getLabelRDF_XML(), LabelsResource.getLabels(), LanguagesResource.getLanguages(), LicensesResource.getLicenses(), DumpResource.getList(), RetcatResource.getQueryResultsARCHWORT(), RetcatResource.getQueryResultsBGS(), RetcatResource.getQueryResultsCHRONONTOLOGY(), RetcatResource.getQueryResultsDBPEDIA(), RetcatResource.getQueryResultsGEONAMES(), RetcatResource.getQueryResultsGettyAAT(), RetcatResource.getQueryResultsGettyTGN(), RetcatResource.getQueryResultsGettyULAN(), RetcatResource.getQueryResultsHeritagedataHE(), RetcatResource.getQueryResultsHeritagedataRCAHMS(), RetcatResource.getQueryResultsHeritagedataRCAHMW(), RetcatResource.getQueryResultsHTML(), RetcatResource.getQueryResultsLabelingSystem(), RetcatResource.getQueryResultsLabelingSystemVocabulary(), RetcatResource.getQueryResultsPELAGIOS(), RetcatResource.getQueryResultsPERSONDB(), RetcatResource.getQueryResultsSkosmosFAO(), RetcatResource.getQueryResultsSkosmosFINTO(), RetcatResource.getQueryResultsSkosmosUNESCO(), RetcatResource.getQueryResultsWIKIDATA(), SearchResource.getResultsLabelingSystem(), RetcatResource.getRetcatDetails(), RetcatResource.getRetcatGroups(), RetcatResource.getRetcatList(), RetcatResource.getRetcatListByVocabulary(), RetcatResource.getRetcatListByVocabularyForList(), RetcatResource.getRetcatQualities(), RetcatResource.getRetcatTypes(), RevisionsResource.getRevision(), RevisionsResource.getRevision_JSON(), RevisionsResource.getRevision_XML(), RevisionsResource.getRevisionRDF_JSONLD(), RevisionsResource.getRevisionRDF_JSONRDF(), RevisionsResource.getRevisionRDF_N3(), RevisionsResource.getRevisionRDF_Turtle(), RevisionsResource.getRevisionRDF_XML(), RevisionsResource.getRevisions(), SparqlResource.getSPARQLresultsGET(), SparqlResource.getSPARQLresultsPOST(), DumpResource.getStatus(), AutocompleteResource.getSuggestionsForAgents(), AutocompleteResource.getSuggestionsForLabels(), AutocompleteResource.getSuggestionsForLabelsFilter(), AutocompleteResource.getSuggestionsForVocabs(), VocabsResource.getVocabularies(), VocabsResource.getVocabulary(), VocabsResource.getVocabulary_JSON(), VocabsResource.getVocabulary_XML(), VocabsResource.getVocabularyRDF_JSONLD(), VocabsResource.getVocabularyRDF_JSONRDF(), VocabsResource.getVocabularyRDF_N3(), VocabsResource.getVocabularyRDF_SKOS(), VocabsResource.getVocabularyRDF_Turtle(), VocabsResource.getVocabularyRDF_XML(), RetcatResource.getWaybackLink(), TestsResource.initTest(), AuthResource.loginUser(), AuthResource.logoutUser(), AgentsResource.postAgent(), LabelsResource.postLabel(), VocabsResource.postVocabulary(), RetcatResource.setRetcatForVocabulary(), RetcatResource.setRetcatForVocabularyForList(), DumpResource.startDumping(), AuthResource.statusUser(), DumpResource.stopDumping(), AgentsResource.updateAgent(), LabelsResource.updateLabel(), RetcatResource.updateRetcatForVocabulary(), RetcatResource.updateRetcatForVocabularyForList(), and VocabsResource.updateVocabulary().