Unverified Commit b1940be7 authored by david-perez's avatar david-perez Committed by GitHub
Browse files

Cosmetic changes in `CombinedErrorGenerator.kt`. (#806)



Co-authored-by: default avatarRussell Cohen <rcoh@amazon.com>
parent 5f6131b5
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@ import software.amazon.smithy.rust.codegen.util.hasTrait
import software.amazon.smithy.rust.codegen.util.toSnakeCase

/**
 * For a given Operation ([this]), return the symbol referring to the unified error? This can be used
 * if you, eg. want to return a unfied error from a function:
 * For a given Operation ([this]), return the symbol referring to the unified error. This can be used
 * if you, e.g. want to return a unified error from a function:
 *
 * ```kotlin
 * rustWriter.rustBlock("fn get_error() -> #T", operation.errorSymbol(symbolProvider)) {
@@ -179,7 +179,7 @@ class CombinedErrorGenerator(
            errors.forEach { error ->
                val errorSymbol = symbolProvider.toSymbol(error)
                val fnName = errorSymbol.name.toSnakeCase()
                writer.rust("/// Returns true if the error kind is `${symbol.name}Kind::${errorSymbol.name}`.")
                writer.rust("/// Returns `true` if the error kind is `${symbol.name}Kind::${errorSymbol.name}`.")
                writer.rustBlock("pub fn is_$fnName(&self) -> bool") {
                    rust("matches!(&self.kind, ${symbol.name}Kind::${errorSymbol.name}(_))")
                }
@@ -207,8 +207,9 @@ class CombinedErrorGenerator(

    /**
     * Generates code to delegate behavior to the variants, for example:
     *
     * ```rust
     *  match self {
     *  match &self.kind {
     *      GreetingWithErrorsError::InvalidGreeting(_inner) => inner.fmt(f),
     *      GreetingWithErrorsError::ComplexError(_inner) => inner.fmt(f),
     *      GreetingWithErrorsError::FooError(_inner) => inner.fmt(f),