Example usage for java.lang IllegalArgumentException getMessage

List of usage examples for java.lang IllegalArgumentException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:net.dv8tion.jda.core.handle.MessageCreateHandler.java

private Long handleDefaultMessage(JSONObject content) {
    Message message;//from  w  w w  .  j av  a2s. c  o  m
    try {
        message = api.getEntityBuilder().createMessage(content, true);
    } catch (IllegalArgumentException e) {
        switch (e.getMessage()) {
        case EntityBuilder.MISSING_CHANNEL: {
            final long channelId = content.getLong("channel_id");
            api.getEventCache().cache(EventCache.Type.CHANNEL, channelId,
                    () -> handle(responseNumber, allContent));
            EventCache.LOG.debug("Received a message for a channel that JDA does not currently have cached");
            return null;
        }
        case EntityBuilder.MISSING_USER: {
            final long authorId = content.getJSONObject("author").getLong("id");
            api.getEventCache().cache(EventCache.Type.USER, authorId, () -> handle(responseNumber, allContent));
            EventCache.LOG.debug("Received a message for a user that JDA does not currently have cached");
            return null;
        }
        default:
            throw e;
        }
    }

    switch (message.getChannelType()) {
    case TEXT: {
        TextChannelImpl channel = (TextChannelImpl) message.getTextChannel();
        if (api.getGuildLock().isLocked(channel.getGuild().getIdLong())) {
            return channel.getGuild().getIdLong();
        }
        channel.setLastMessageId(message.getIdLong());
        api.getEventManager().handle(new GuildMessageReceivedEvent(api, responseNumber, message));
        break;
    }
    case PRIVATE: {
        PrivateChannelImpl channel = (PrivateChannelImpl) message.getPrivateChannel();
        channel.setLastMessageId(message.getIdLong());
        api.getEventManager().handle(new PrivateMessageReceivedEvent(api, responseNumber, message));
        break;
    }
    case GROUP: {
        GroupImpl channel = (GroupImpl) message.getGroup();
        channel.setLastMessageId(message.getIdLong());
        api.getEventManager().handle(new GroupMessageReceivedEvent(api, responseNumber, message));
        break;
    }
    default:
        WebSocketClient.LOG
                .warn("Received a MESSAGE_CREATE with a unknown MessageChannel ChannelType. JSON: " + content);
        return null;
    }

    //Combo event
    api.getEventManager().handle(new MessageReceivedEvent(api, responseNumber, message));

    //        //searching for invites
    //        Matcher matcher = invitePattern.matcher(message.getContent());
    //        while (matcher.find())
    //        {
    //            InviteUtil.Invite invite = InviteUtil.resolve(matcher.group(1));
    //            if (invite != null)
    //            {
    //                api.getEventManager().handle(
    //                        new InviteReceivedEvent(
    //                                api, responseNumber,
    //                                message,invite));
    //            }
    //        }
    return null;
}

From source file:com.realdolmen.rdfleet.webmvc.controllers.rd.OrderCarController.java

@RequestMapping(value = "/freepool/{id}", method = RequestMethod.GET)
public String getFreePoolCar(@PathVariable("id") Long id,
        @ModelAttribute("employeeCar") EmployeeCar employeeCar, Model model) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    try {// w ww. java2  s .c o m
        boolean canOrderEmployeeCar = employeeService.employeeCanOrderEmployeeCar(auth.getName(),
                employeeCar.getId());
        if (!canOrderEmployeeCar)
            return "redirect:/rd/cars/freepool";
        EmployeeCar employeeCarFromService = employeeCarService.findById(id);
        employeeCar.setCarOptions(employeeCarFromService.getCarOptions());
        employeeCar.setCarStatus(employeeCarFromService.getCarStatus());
        employeeCar.setLicensePlate(employeeCarFromService.getLicensePlate());
        employeeCar.setSelectedCar(employeeCarFromService.getSelectedCar());
        employeeCar.setMileage(employeeCarFromService.getMileage());
        employeeCar.setId(employeeCarFromService.getId());
        employeeCar.setVersion(employeeCarFromService.getVersion());
        model.addAttribute("employeeCar", employeeCar);
        model.addAttribute("car", carService.findById(employeeCar.getSelectedCar().getId()));
        model.addAttribute("canOrderFreePoolCar", canOrderEmployeeCar);
    } catch (IllegalArgumentException e) {
        model.addAttribute("error", e.getMessage());
    }
    return "rd/freepool.detail";
}

From source file:com.varoid.exoplanethunter.JSONParser.java

public void readJSONFeed(String URL) throws Exception {
    this.ret = "ff";
    StringBuilder stringBuilder = new StringBuilder();
    HttpClient httpClient = new DefaultHttpClient();
    this.ret = "wdsffdfdg";

    try {/*from  w  w w.j av a2  s . c  o  m*/

        httpGet = new HttpGet(URL);
    } catch (IllegalArgumentException e) {

        this.ret = "ucvt589hygf " + e.toString() + e.getMessage();
    }
    this.ret = "wdsfsdedg";
    try {
        HttpResponse response = httpClient.execute(httpGet);

        StatusLine statusLine = response.getStatusLine();
        int statusCode = statusLine.getStatusCode();
        if (statusCode == 200) {
            this.ret = "wedfgdfgg";
            HttpEntity entity = response.getEntity();
            InputStream inputStream = entity.getContent();
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
            String line;
            while ((line = reader.readLine()) != null) {
                stringBuilder.append(line);
            }
            inputStream.close();
        } else {
            this.ret = "Failed to download file";
        }
    } catch (Exception e) {
        this.ret = "readJSONFeed" + e.toString();
    }
    this.ret = stringBuilder.toString();
}

From source file:org.artifactory.rest.resource.bintray.BintrayResource.java

@POST
@Path("docker/push/{repoKey}")
@Consumes(MediaType.APPLICATION_JSON)/*from ww w  .j a va  2 s . c  o  m*/
public Response pushDockerTag(@PathParam("repoKey") String repoKey, BintrayDockerPushRequest request)
        throws IOException {
    if (!BintrayRestHelper.isPushToBintrayAllowed()) {
        throw new AuthorizationRestException();
    }

    if (StringUtils.isBlank(request.dockerRepository) || StringUtils.isBlank(request.dockerTagName)) {
        throw new BadRequestException("You must provide dockerRepository and dockerTagName");
    }

    if (StringUtils.isBlank(request.bintraySubject) || StringUtils.isBlank(request.bintrayRepo)) {
        throw new BadRequestException("You must provide bintraySubject and bintrayRepo");
    }

    try {
        DockerAddon dockerAddon = addonsManager.addonByType(DockerAddon.class);
        dockerAddon.pushTagToBintray(repoKey, request);
        return request.async
                ? Response.status(HttpStatus.SC_ACCEPTED).entity("Docker tag pushing to Bintray accepted.")
                        .build()
                : Response.ok("Docker tag successfully pushed to Bintray").build();
    } catch (IllegalArgumentException e) {
        throw new BadRequestException(e.getMessage());
    }
}

From source file:com.streamsets.pipeline.stage.origin.remote.TestFileFilter.java

@Test
public void testGlobToRegexSpecialCharacters() {
    FileFilter filter = new FileFilter(FilePatternMode.GLOB, "abc.def.");
    Assert.assertEquals("abc\\.def\\.", filter.getRegex().pattern());

    String[] illegalPatterns = new String[] { ".abc", "abc/def", "abc~def" };
    for (String illegalPattern : illegalPatterns) {
        try {/*from www .  j  av a2s .  c o m*/
            new FileFilter(FilePatternMode.GLOB, illegalPattern);
            Assert.fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            Assert.assertEquals("Invalid character in file glob", e.getMessage());
        }
    }
}

From source file:com.github.springtestdbunit.bean.DatabaseDataSourceConnectionFactoryBeanTest.java

@Test
public void shouldNotAllowObjectWithoutDataSet() throws Exception {
    try {/*from   ww w  .ja  va 2  s .  c om*/
        this.factoryBean.getObject();
        fail();
    } catch (IllegalArgumentException ex) {
        assertEquals("The dataSource is required", ex.getMessage());
    }
}

From source file:commonline.query.gui.CommonlineRecordRepositoryTest.java

public void test_save_couldNotFindDataSource() {
    try {/* w  ww . j  av  a 2 s  .c om*/
        repository.save(null, FileVersion.CL5);
        fail();
    } catch (IllegalArgumentException err) {
        assertEquals("Could not find datasource for CL5", err.getMessage());
    }

}

From source file:org.terasoluna.gfw.web.download.FileDownloadViewTest.java

@Test
public void testAfterPropertiesSet_chunkSize_is0() throws IOException {
    // Set Mock Behavior
    fileDownloadView.setChunkSize(0);/* w  w  w .j  a  v  a 2s.  c  o  m*/
    try {
        fileDownloadView.afterPropertiesSet();
        fail("must occur IllegalArgumentException.");
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), is("chunkSize must be over 1. specified chunkSize is \"0\"."));
    }
}

From source file:org.terasoluna.gfw.web.download.FileDownloadViewTest.java

@Test
public void testAfterPropertiesSet_chunkSize_isNegative1() throws IOException {
    // Set Mock Behavior
    fileDownloadView.setChunkSize(-1);// w  w  w.jav  a  2  s .  co m
    try {
        fileDownloadView.afterPropertiesSet();
        fail("must occur IllegalArgumentException.");
    } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), is("chunkSize must be over 1. specified chunkSize is \"-1\"."));
    }
}

From source file:edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectionSetup.java

private void forceLocale() {
    try {//from   ww  w.  jav  a  2  s .c  o  m
        Locale forceLocale = buildLocale(forceString);
        SelectedLocale.setForcedLocale(ctx, forceLocale);
        ssInfo("Setting forced locale to '" + forceLocale + "'.");
    } catch (IllegalArgumentException e) {
        ssWarning("Problem in '" + PROPERTY_FORCE_LOCALE + "': " + e.getMessage());
    }
}