Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.5%) to scientific vocabulary

Keywords

exceptions factory-method-pattern java

Keywords from Contributors

mesh interactive
Last synced: 4 months ago · JSON representation ·

Repository

Basic Info
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 4
Topics
exceptions factory-method-pattern java
Created 5 months ago · Last pushed 5 months ago
Metadata Files
Readme Funding License Citation Codeowners

README.md

Exception Factory

Create Exception instances with Factory-methods and Builder patterns!

Import the Dependency

xml <dependency> <groupId>io.github.chrimle</groupId> <artifactId>exception-factory</artifactId> <version>0.4.0</version> </dependency>

Example Usage

There are several ways of instantiating Exceptions using exception-factory. Here are some examples, given in the order of quick-and-easy to more customized Exceptions.

1. Using ExceptionFactory

Offers the creation of IllegalArgumentExceptions and IllegalStateExceptions, in the following ways:

```java import io.github.chrimle.exceptionfactory.ExceptionFactory; import io.github.chrimle.exceptionfactory.MessageTemplates;

import java.util.regex.Pattern;

import static io.github.chrimle.exceptionfactory.MessageTemplates.OneArgTemplate.*; import static io.github.chrimle.exceptionfactory.MessageTemplates.TwoArgTemplate.MUSTMATCHREGEX;

// Example of ExceptionFactory static { // Example of a One-Arg MessageTemplate, which throws "username MUST NOT be null". if (username == null) throw ExceptionFactory.illegalArgumentOf("username", MUSTNOTBE_NULL);

// Example of a Two-Arg MessageTemplate, which throws "username MUST match the RegEx ^[a-z]{3,15}$". if (!Pattern.matches("^[a-z]{3,15}$", username)) throw ExceptionFactory.illegalArgumentOf("username", MUSTMATCHREGEX, "^[a-z]{3,15}$"); } `` Refer to [MessageTemplates](src/main/java/io/github/chrimle/exceptionfactory/MessageTemplates.java) for all available *message templates*. These are separated by how many *format specifiers* are needed, i.e.OneArgTemplaterequires ***one*** argument to format the resultingString`. For custom messages, and/or providing a cause, see section below.

2. Using ExceptionBuilder

Offers the creation of any Exception-class, via a builder-pattern. This class is used by ExceptionFactory internally.

```java import io.github.chrimle.exceptionfactory.ExceptionBuilder; import io.github.chrimle.exceptionfactory.MessageTemplates;

import static io.github.chrimle.exceptionfactory.MessageTemplates.TwoArgTemplate.*;

// Example of ExceptionBuilder

static { if (1 + 1 == 3) { // Creating a plain Exception without message/cause. throw ExceptionBuilder.of(MakesNoSenseException.class).build(); }

try { oldUsername = userRepository.getUsername(userId); } catch (NoSuchUserException exception) { // Creating an exception with a custom message and cause. throw ExceptionBuilder.of(IllegalArgumentException.class) .setMessage("No user with userId '%s' exists!"::formatted, userId) .setCause(exception) .build(); } catch (ExceptionalException exception) { // Creating an exception with a custom format message string and cause. throw ExceptionBuilder.of(IllegalStateException.class) .setMessage("No clue what happened. Time to log everything %s, %s, %s, %s, %s", userId, newUsername, newLanguage, newDescription) .setCause(exception) .build(); }

// Creating an exception with a MessageTemplate. (Similar to ExceptionFactory) if (newUsername == oldUsername) throw ExceptionBuilder.of(IllegalArgumentException.class) .setMessage(MUSTNOTBEEQUALTO, "newUsername", oldUsername) .build(); } ```

JavaDocs

Please refer to the JavaDocs for further explanations.

Owner

  • Name: Christopher Molin
  • Login: Chrimle
  • Kind: user
  • Location: Gothenburg
  • Company: Chrimle.com

Software Engineer

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you want to reference this project, you could cite it as below."
authors:
- family-names: "Molin"
  given-names: "Christopher"
  orcid: "https://orcid.org/0009-0002-1005-3942"
title: "Exception Factory"
version: 0.4.0
date-released: 2025-08-03
url: "https://github.com/Chrimle/Exception-Factory"

GitHub Events

Total
  • Release event: 3
  • Watch event: 1
  • Delete event: 10
  • Issue comment event: 1
  • Push event: 14
  • Pull request event: 30
  • Create event: 16
Last Year
  • Release event: 3
  • Watch event: 1
  • Delete event: 10
  • Issue comment event: 1
  • Push event: 14
  • Pull request event: 30
  • Create event: 16

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 5
  • Total Committers: 2
  • Avg Commits per committer: 2.5
  • Development Distribution Score (DDS): 0.2
Past Year
  • Commits: 5
  • Committers: 2
  • Avg Commits per committer: 2.5
  • Development Distribution Score (DDS): 0.2
Top Committers
Name Email Commits
Christopher Molin 2****e 4
dependabot[bot] 4****] 1

Issues and Pull Requests

Last synced: 5 months ago

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
repo1.maven.org: io.github.chrimle:exception-factory

Create Exception instances with Factory-methods and Builder patterns!

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 32.9%
Average: 39.9%
Dependent packages count: 47.0%
Last synced: 4 months ago

Dependencies

.github/workflows/maven-publish.yml actions
  • actions/checkout v4 composite
  • actions/setup-java v4 composite
.github/workflows/maven.yml actions
  • actions/checkout v4 composite
  • actions/setup-java v4 composite
.github/workflows/pullRequestAudit.yml actions
  • actions/github-script v6 composite
pom.xml maven