how to show the exception message occurred on a modal for an angular project

Discussão em 'Angular' iniciado por ackbNow, Novembro 11, 2024.

  1. ackbNow

    ackbNow Guest

    every time I upload an invalid file java throws an exception now I want to show the message on the frontend screen when it happens. Note : I am using an angular project.

    controller code

    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces(MediaType.APPLICATION_JSON)
    public Response validateUpload(@FormDataParam("file") InputStream uploadedInputStream,
    @FormDataParam("file") FormDataContentDisposition fileDetails,
    @FormDataParam("uploadType") String uploadtype, @FormDataParam("aquiName") String aquiName) {

    logger.debug("Received call to process Auto Account Import template id {}", uploadtype);

    AccountImportType template = AccountImportType.valueOfSafe(uploadtype);
    if (template == null)
    return Response.status(Status.NOT_FOUND).entity("Template not found").build();

    try {
    ImportValidationResult results = importProcessor.doValidation(template, uploadedInputStream);

    return Response.ok().entity(results).build();
    } catch (TemplateNotReadableException e) {
    logger.error("Failed to process upload", e);
    return Response.status(Status.NOT_ACCEPTABLE).entity(e.getMessage()).build();
    }
    }


    these errors in the controller are printing on chrome console I needed them to be on screen so that user is notified.

    Continue reading...

Compartilhe esta Página