Vue alert message handling - jhipster

I love the vue.js impl.. so easy and fast to develop with but it appears that the error handling for api errors is not working (not the same as with react.js anyway).
E.g. if I try to save an entity with a field value that is supposed to be unique (but is not) then the page does not display any error alert at all. I do see one in the js console, but it looks like its not handled in the ui code.
Is there something more I need to do ?

Related

report error whenever an error occur in project

My requirement is to send the error to developers whenever an error occurs in the project (ex: unable to fetch the user from the database, var x is not defined, myfun() is not a function etc.)
We are using
NODE for backend language
Express for routing
GCP for deployment
PM2 package for management
Express default error handling is not working because we have many async codes, and it's very difficult to check and modify the project using express next() function.
I didn't find any way to report project error via GCP
and report error via pm2 is not working
Please tell me any third party package to report project errors or any other way of reporting.
User Stackdriver as already advised, and for Stackdriver to be useful, make sure that all errors are logged properly in your code, so that meaningful error messages are displayed in your Stackdriver reports.
Check this post for different methods of catching errors with Javascript, and how to deal with asynchronous calls.

Correct reporting on RESTful-APIs

A part of Application insights, is where it shows the 4xx errors and of course it makes sense for example when a page or media has been requested but it doesn't exists. But when it comes to logic of your application, it becomes annoying.
For instance, lets say the one has to validate title of a post to make sure it follows some rules (like not having curse words, not being duplicate, etc.).
I will implement this as a service "VerifyTitle" and return corresponding 4xx response with a message to Front-end and they need to just check for 4xx and show the message.
The code is simple and works perfectly fine and the user will see the expected behavior on the page, but in the application insights I have 100 Failures :\
You can't blame Application Insights for not being able to distinguish logical errors build in by the developer from real world (connectivity) issues.
That said, you might be able to exclude them using custom telemetry filters, see the docs. But then you should provide a way to tell the differences. You can use the request path for example to exclude certain endpoint or something else.

Supporting Server side validation with ServiceStack.Razor

I have a Service which, depending on content type, either uses Razor to return HTML or returns JSON. When in HTML mode I want to support server side (non-JavaScript) validation of Forms. I wish to rely on the repository for validation, if the repo returns an error I re-display the form along with the error message from the repo.
The model I am using is this:
in json mode simply throw an Exception
in HTML mode return a response containing both the partially created object and the response status.
This allows me to re-display the form using the same View that I would use when editing an existing object and also display the error message contained in Model.ResponseStatus.Message.
My question: Does anyone have any thoughts on how well I am using the facilities provided by ServiceStack? Is there a better, cleaner, simpler way?

Node validation in jade template

I'm extremely new to node.js, and have years of experience in PHP, so my thinking about the issues below, might be tainted by my backed ways.
I'm currently using node set up with foundation CSS, and using their reveal modal windows to display most of my forms. I want to avoid re-displaying them upon submit, and instead, validate them on client side.
Basic user creation will have fields as per below:
name
email
password
password confirmation
Form my basic validation i can use require to validate the input,
input(type="text",name="user[email]",placeholder="#",required)
but I would also like the client to check if the email already exists after the user types it in, and whether the passwords are correct.
I've been reading about the validator module but from the documentation I read about it, I only understand how to validate the values after they've been posted. I've seen the express-form module as well, but It's no longer maintained, so I would rather avoid it.
Could someone point me in the right direction?
I don't have any experience with validator or express-form, and I am not sure you need them for what you are trying to achieve. Most of what you are trying to do will be client side work (e.g. jQuery Ajax calls to validate the data) That kind of client-side code should be pretty much the same regardless of whether you use a Node.js backend or a PHP backend.
Injecting the initial JavaScript in your Jade page should be pretty straightforward once you figure out the proper syntax to include JavaScript in a Jade page. The wiring of DOM events on the page to make Ajax calls (onClick, onTextChanged, et cetera) will be conceptually the same as if you were writing a plain HTML page.
In your Node.js server side you'll need a route to handle the request to validate if an e-mail address already exists and that code very likely will return JSON that you will use in your client side form to display the results of the validation to the user. But that should also be very similar to what you would have done with a PHP backend.

How to avoid users getting 500 Errors when server throw exception

I get the following errors in my server log.
2012-03-06 09:20:43 HTTP JVM: CLFAD0211E: Exception thrown. For more detailed information, please consult error-log-0.xml located in D:/Lotus/Domino/data/domino/workspace/logs
2012-03-06 09:20:43 HTTP JVM: CLFAD0229E: Security exception occurred servicing request for: /demo.nsf/home.xsp - HTTP Code: 500. For more detailed information, please consult error-log-0.xml located in D:/Lotus/Domino/data/domino/workspace/logs
The user only sees this in the webbrowser (source)
<html>
<head>
<title>Error</title></head>
<body text="#000000">
<h1>Error 500</h1>HTTP Web Server: Command Not Handled Exception</body>
</html>
So I can tell by the server log that there is a security exception thrown at the server, probably because I have wrong settings in my java.policy file. but my issue is not what is causing the error, but rather how can I avoid users getting these ugly 500 errors.
I would like the error page I have set in the application to be presented to the user just like any other exception.
possible?
The more try/catch blocks you have in your code, the better (within reason, of course):
try {
// code that might throw an error
} catch (e) {
// examine the error to see if there's a workaround
// if not, log it and inform the user
} finally {
// any code that needs to run whether or not there was an error
}
This way if something fails, it fails gracefully. Just be sure to make it obvious to the user that something went wrong (and, preferably, provide them instructions they can actually follow up on)... failing silently is even worse than an ugly error page if something went wrong and the user thinks everything was fine.
P.S. As Stephan indicates, there are some errors that simply can't be caught. If the XPage wasn't signed by someone with access to run XPages, for instance, it never even gets to the point of trying to run your code... the page itself is invalid, so there's nothing you can do at runtime. Always make sure that your XPages are signed during deployment.
There are a number of errors that "break through" even if you have an error page defined. E.g. when you drag a control onto itself. Security seems another area. All of them are stuff you should handle in development. I haven't seen errors that "typically" happen (true runtime after development completed and tested type of errors) escaping a custom error page. Other than that follow Declan's advice.
I had an issue like this also where my error page was not being displayed and the error 500 page would display instead.
What I discovered is that there was a problem in my error page also and the renderer therefore can't display the error for the original page and you get the server default error page instead.
The best way to check if this is the cause of your particular issue is to start with a simple error page, no theme, no ssjs libraries, no ssjs code on the page etc, just a blank xpage with some static text to indicate that it is the error page.
Once you can confirm that this is the possible cause of the error 500 then you can start building up that error page and add in the dynamic stuff bit by bit till it is the way you need it.
Dmytro Pastovenskyi has a good article http://dpastov.blogspot.com/2012/01/error-pages-in-domino.html about error pages in Domino.
To be on the safe side I have a static html page saying "An error occured". This page is referenced by the HTTPMultiErrorPage setting in the notes.ini on your server.
Then there is a "HTTP response headers" rule addressing special error codes.
The main problem still is, that these are global settings. So there is no easy way to catch all errors specially for your application. But a least the user don't get this annoying white error page.
I have had similar issues with this. Error messages bubbling up from some underlying fault that overrides the defined error page for the application. This is not a nice behavior (from a user perspective) and makes you feel a bit naked. I do understand that it's hard for the application to trap those - but there should at least be a way to customize that message - The default error 500 page is not very useful for a normal user anyway...
The only(?) way to try to avoid that your code throws such error (ssjs/java) is to (as Tim Tripcony already mentioned) always use try/catch statements around the code (as you already know :))
getDocumentByUNID() is a "good" example of a method that will cause the ugly (but standard) error 500 page to be displayed instead of the defined one in the app.
As for any other error types (system/security and such) - I don't think it's possible to redirect those to the (by the user) invoked applications error page because they are not invoked from the application but rather before the application is invoked (I hope I'm wrong).
Make a new XPage called error.xsp (for example). Put there some basic info that something went wrong, apologize for that fact and provide few links how to continue with the work (even though his/her data may be lost forever - history.go(-1) usually does not resolve the problem). In the background you can log the error (usage of OpenLog recommended).
Open Application Properties, XPages tab. Uncheck Display XPages runtime error page. In the combo Error page select your page (error).

Resources