Loading codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/error/CombinedErrorGenerator.kt +10 −9 Original line number Diff line number Diff line Loading @@ -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)) { Loading Loading @@ -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}(_))") } Loading Loading @@ -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), Loading Loading
codegen/src/main/kotlin/software/amazon/smithy/rust/codegen/smithy/generators/error/CombinedErrorGenerator.kt +10 −9 Original line number Diff line number Diff line Loading @@ -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)) { Loading Loading @@ -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}(_))") } Loading Loading @@ -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), Loading