Mixfaa / excify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Excify

(beta)

Tool to make exceptions Faster / more flexible (in future) / less word expensive

Use cases:

  • Automatically generate .exceptionName() methods for companion object
  • generate .get() method for cached exception
  • generate .orThrowUserNotFound() methods for Optional and User? receivers (for example)
  • More use cases in future!

Lets look at some code

Example 1

// exception class
/**
 * FastException- Throwable without stacktrace writing
 */

class NotFoundException(subject: String) : FastException("$subject not found!") {
    companion object
}

@ExcifyCachedException
val userNotFoundException = NotFoundException("User")

/* 
It will generate NotFoundException.userNotFound() method, which will return userNotFoundException object
 */

Example 2

@ExcifyCachedException
@ExcifyOptionalOrThrow(type = Product::class, methodName = "orThrow")
val productNotFound = NotFoundException("Product")

/*
It will generate 
1) NotFoundException.productNotFound()
2) Optional<Product>.orThrow() method, which will throw productNotFound or return Product 
3) Product?.orThrow() method, with same as Optional<Product> logic
 */

About


Languages

Language:Kotlin 100.0%