Kendo Grid, how to handle error while fetching data from server - kendo-grid

How to handle exception from Rest service "testReportReadUrl" in grid, Currently Grid displaying no records and not showing exception message.
<kendo:dataSource pageSize="20" serverPaging="true"
serverSorting="true" serverFiltering="true" serverGrouping="true">
<kendo:dataSource-transport>
<kendo:dataSource-transport-read url="${testReportReadUrl}"
type="POST" contentType="application/json" />
</kendo:dataSource-transport>

Need to add error ="errorHandler" with data source as below
<kendo:dataSource pageSize="20" serverPaging="true"
serverSorting="true" serverFiltering="true" serverGrouping="true" error="handleError">
<kendo:dataSource-transport>
<kendo:dataSource-transport-read url="${testReportReadUrl}"
type="POST" contentType="application/json" />
</kendo:dataSource-transport>
And provide handler method
function handleError(e){
alert("An error occurred")
}

Related

How can I make Feathers (Express-based API Framework) Return Error Responses

I've read the Feathers book, so I know that to create an error response I simply instantiate the appropriate feathers-errors class:
import {BadRequest} from 'feathers-errors';
const errorResponse = new BadRequest(`foo`, `bar`);
However, I'm having difficulty returning that error response to the user. Even when I create an endpoint that does nothing but return an error response ...
class SomeService {
create(data) {
return new BadRequest(`foo`, `bar`);
}
}
it doesn't work: instead of getting an error response, I get no response, and inside the Chrome debugger I can see that the response is pending (until it eventually times out and becomes an ERR_EMPTY_RESPONSE).
I tried reading about Express error handling, and in the examples I saw people used next to wrap the the response. However, next comes from the error handler, and I'm not sure where in my Feathers code I can get that next function.
If anyone could help explain (using next or not) how I can return a complete, not pending, error response, I would greatly appreciate it.
Your services have to return a promise. If your code is not asynchronous you can turn it into a promise with Promise.resolve and Promise.reject:
class SomeService {
create(data) {
return Promise.reject(new BadRequest(`foo`, `bar`));
}
}
Also make sure you registered the Express error handler to get nicely formatted errors:
const errorHandler = require('feathers-errors/handler');
// Last in the chain
app.use(errorHandler);
There is also more information in the error handling chapter.

String index error in Grails Google Charts plugin

I have some strings that are in array form in a MySQL database that I want to use in the Grails Google Charts plugin, but I’m having trouble getting the plugin to accept them.
My strings look like [['string', 'Month'], ['number', 'Stories']] and [['April', 0], ['May', 0], ['June', 0], ['July', '12152']], which is the correct format, but I’m getting a "string index out of range error" that I'm trying to resolve.
I’m using g:set to set the variables and then passing them to gvisualization:
<g:each in="${groupsInstance.charts}" var="c">
<g:set var="chartColumns" value="${c.chartColumns}" />
<g:set var="chartData" value="${c.chartData}" />
<g:set var="chartType" value="${c.chartType}" />
<g:set var="chartDisplayKey" value="${chartType.chartKey}" />
<g:if test="${c.id == 1}">
<gvisualization:columnCoreChart elementId="${chartDisplayKey}"
width="${225}"
height="${225}"
legend="none"
columns="${chartColumns}"
data="${chartData}" />
</g:if>
</g:each>
When I try to do it this way, I get the following error in the app:
Error 500: Internal Server Error
URI: /appDash/groups/show/1
Class: java.lang.StringIndexOutOfBoundsException
Message: String index out of range: 2
And the console:
Error |
2014-08-12 12:36:51,717 [http-bio-8080-exec-6] ERROR errors.GrailsExceptionResolver - StringIndexOutOfBoundsException occurred when processing request: [GET] /app/groups/show/1
String index out of range: 2. Stacktrace follows:
Message: Error processing GroovyPageView: Error executing tag <gvisualization:columnCoreChart>: String index out of range: 2
If I initialize variables at the top of the page and use those instead, it works fine; the error occurs when I try to pull the strings out of the database. I’ve tried to find examples of the plugin being used this way without much success.

Alfresco Workflow: How to set association value when update "Task" by REST Json?

My application is interacting with Alfresco workflow by REST.
There is a task having association to an object of type cm:person, its value should be collected form the end user -to be used as assignee of the next task-. How can I set this value by REST ??
I tried to send HTTP "PUT" request (content-type:application/json) on URL
http://localhost:8080/alfresco/service/api/task-instances/activiti$11102
and body request is:
{
"cio_employee": "workspace://SpacesStore/bcb9817f-5778-484b-be16-a388eb18b5ab" }
where "workspace://SpacesStore/bcb9817f-5778-484b-be16-a388eb18b5ab" is the reference of admin person, but when I end the task (by REST also), Alfresco throws error:
...
Caused by: org.activiti.engine.ActivitiException: Unknown property
used in expression: ${cio_employee.properties.userName} ... Caused by:
org.activiti.engine.impl.javax.el.PropertyNotFoundException: Could not
find property properties in class java.lang.String
Below is the task and its model definition:
//User Task:
<userTask id="assignHandler" name="Assign Employee" activiti:assignee="admin"
activiti:formKey="cio:assignEmployeeTask">
<documentation>Please, Assign employee to the next task</documentation>
<extensionElements>
<activiti:taskListener event="complete"
class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
execution.setVariable('cio_employee',
task.getVariable('cio_employee'));
</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
</userTask>
///////////////////////////////////////////////////////////
//Model
...
<types>
...
<type name="cio:assignEmployeeTask">
<parent>bpm:workflowTask</parent>
<mandatory-aspects>
<aspect>cio:employee</aspect>
</mandatory-aspects>
</type>
...
</types>
...
<aspects>
<aspect name="cio:employee">
<associations>
<association name="cio:employee">
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cm:person</class>
<mandatory>true</mandatory>
<many>false</many>
</target>
</association>
</associations>
</aspect>
</aspects>
////////////////////////////////////////////////////////////////////////
After searching deeply, you will need to send POST request on
http://localhost:8080/alfresco/s/api/task/[taskId]/formprocessor
with body:
{
"assoc_cio_employee_added": "workspace://SpacesStore/bcb9817f-5778-484b-be16-a388eb18b5ab"
}
and for removing use the key "assoc_cio_employee_removed"
https://wiki.alfresco.com/wiki/Forms_Developer_Guide
Hope it may help someone.
Alfresco Version 4.2.e

WCF WebFaultException ExceptionDetail

I'm creating a WCF service that returns data in JSON Format. I'm trying to figure out how to best handle exceptions and I'm trying to use the WebFaultException class to return an exception detail message in the response, which can later be outputted to the user.
A simple Test of this method I am trying is as follows
The WCF Service method
<WebInvoke(Method:="POST",
ResponseFormat:=WebMessageFormat.Json)>
<OperationContract()>
Public Function Test() As Object
Throw New WebFaultException(Of String)("Message Details", Net.HttpStatusCode.NotFound)
End Function
From what I found searching for answers to this questions, you should give the service a behaviorconfiguartion which sets includeExceptionDetailInFaults to true.
My Web.Config
<service name="WebserviceExceptionTest.Service" behaviorConfiguration="behavior">
<endpoint address="" behaviorConfiguration="WebserviceExceptionTest.ServiceAspNetAjaxBehavior"
binding="webHttpBinding" contract="WebserviceExceptionTest.Service" />
</service>
<serviceBehaviors>
<behavior name="behavior">
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
Unfortunately, this appears to not do the trick for me and the response still does not include the exception detail, the JSON string looks like this:
{"ExceptionDetail":null,"ExceptionType":null,"Message":"Not Found","StackTrace":null}
Does anyone have any idea of what it is I am doing wrong, or am I just entirely on the wrong path? Thanks!
Edit
The Response I'm getting is always "500 Internal server error" Even though I'd expect it to get a 400 not found. The Error message does contain the "No Content" though.
Set your automaticFormatSelectionEnabled to be false, defaultOutgoingResponseFormat to Json (I believe it even ignores ResponseFormat:=WebMessageFormat.Json)
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat ="Json" />
http://msdn.microsoft.com/en-us/library/system.servicemodel.description.webhttpendpoint.automaticformatselectionenabled.aspx

How to get the JSON response from the Greenhopper REST API in Gadget?

I am not able to get the response from the GreenHopper REST API for the url http://:2990/jira/rest/greenhopper/1.0/sprints/1 through my Gadget application.
I able to get the following output when I try it from Browser, Below is the Output.
{"sprints":[{"id":1,"name":"Sprint 1","closed":false}],"rapidViewId":1}
My Code snippet to retrive the sprint details in Gadget is :
args: {
key: "sprints",
ajaxOptions: function () {
return {
url: "/rest/greenhopper/1.0/sprints/1",
};
}
}
Can anybody sugget me how to get the JSON Response from greenhopper REST API for a JIRA dashboard.
I am getting following Exception in Server:
[talledLocalContainer] at java.lang.Thread.run(Thread.java:662)
[talledLocalContainer] 2013-04-25 15:26:58,985 http-2990-11 ERROR admin 926x5323x1 dggnll 172.27.186.82 /rest/greenhopper/1.0/sprints/1
[common.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service
[talledLocalContainer] javax.ws.rs.WebApplicationException
[talledLocalContainer] at com.sun.jersey.server.impl.uri.rules.TerminatingRule.accept(TerminatingRule.java:66)
[talledLocalContainer] at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
That's the right URL so maybe the sprint doesn't exist or you don't have permission to view it? Also, try using the Developer Workbox add-on and the REST API browser to test these kind of methods.