Skip to content

Commit

Permalink
regenerte code
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgoss committed Nov 9, 2023
1 parent 9cc3d8a commit 13dd4cc
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 6 deletions.
1 change: 1 addition & 0 deletions cpp/include/cucumber/messages/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct exception
{
std::string type;
std::optional<std::string> message;
std::optional<std::string> stack_trace;

std::string to_string() const;

Expand Down
2 changes: 2 additions & 0 deletions cpp/src/lib/cucumber-messages/cucumber/messages/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exception::to_string() const

cucumber::messages::to_string(oss, "type=", type);
cucumber::messages::to_string(oss, ", message=", message);
cucumber::messages::to_string(oss, ", stack_trace=", stack_trace);

return oss.str();
}
Expand All @@ -21,6 +22,7 @@ exception::to_json(json& j) const
{
cucumber::messages::to_json(j, camelize("type"), type);
cucumber::messages::to_json(j, camelize("message"), message);
cucumber::messages::to_json(j, camelize("stack_trace"), stack_trace);
}

std::string
Expand Down
5 changes: 3 additions & 2 deletions go/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ type Envelope struct {
}

type Exception struct {
Type string `json:"type"`
Message string `json:"message,omitempty"`
Type string `json:"type"`
Message string `json:"message,omitempty"`
StackTrace string `json:"stackTrace,omitempty"`
}

type GherkinDocument struct {
Expand Down
19 changes: 16 additions & 3 deletions java/src/generated/java/io/cucumber/messages/types/Exception.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@
public final class Exception {
private final String type;
private final String message;
private final String stackTrace;

public Exception(
String type,
String message
String message,
String stackTrace
) {
this.type = requireNonNull(type, "Exception.type cannot be null");
this.message = message;
this.stackTrace = stackTrace;
}

/**
Expand All @@ -41,21 +44,30 @@ public Optional<String> getMessage() {
return Optional.ofNullable(message);
}

/**
* The stringified stack trace of the exception that caused this result
*/
public Optional<String> getStackTrace() {
return Optional.ofNullable(stackTrace);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Exception that = (Exception) o;
return
type.equals(that.type) &&
Objects.equals(message, that.message);
Objects.equals(message, that.message) &&
Objects.equals(stackTrace, that.stackTrace);
}

@Override
public int hashCode() {
return Objects.hash(
type,
message
message,
stackTrace
);
}

Expand All @@ -64,6 +76,7 @@ public String toString() {
return "Exception{" +
"type=" + type +
", message=" + message +
", stackTrace=" + stackTrace +
'}';
}
}
2 changes: 2 additions & 0 deletions javascript/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export class Exception {
type: string = ''

message?: string

stackTrace?: string
}

export class GherkinDocument {
Expand Down
1 change: 1 addition & 0 deletions messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ will only have one of its fields set, which indicates the payload of the message
| ----- | ---- | ----------- | ----------- |
| `type` | string | yes | |
| `message` | string | no | |
| `stackTrace` | string | no | |

## GherkinDocument

Expand Down
12 changes: 12 additions & 0 deletions perl/lib/Cucumber/Messages.pm
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ use Scalar::Util qw( blessed );
my %types = (
type => 'string',
message => 'string',
stack_trace => 'string',
);

# This is a work-around for the fact that Moo doesn't have introspection
Expand Down Expand Up @@ -580,6 +581,17 @@ has message =>
);


=head4 stack_trace
The stringified stack trace of the exception that caused this result
=cut

has stack_trace =>
(is => 'ro',
);


}

package Cucumber::Messages::GherkinDocument {
Expand Down
17 changes: 17 additions & 0 deletions php/src-generated/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public function __construct(
* The message of exception that caused this result. E.g. expected: "a" but was: "b"
*/
public readonly ?string $message = null,

/**
* The stringified stack trace of the exception that caused this result
*/
public readonly ?string $stackTrace = null,
) {
}

Expand All @@ -47,10 +52,12 @@ public static function fromArray(array $arr): self
{
self::ensureType($arr);
self::ensureMessage($arr);
self::ensureStackTrace($arr);

return new self(
(string) $arr['type'],
isset($arr['message']) ? (string) $arr['message'] : null,
isset($arr['stackTrace']) ? (string) $arr['stackTrace'] : null,
);
}

Expand All @@ -76,4 +83,14 @@ private static function ensureMessage(array $arr): void
throw new SchemaViolationException('Property \'message\' was array');
}
}

/**
* @psalm-assert array{stackTrace?: string|int|bool} $arr
*/
private static function ensureStackTrace(array $arr): void
{
if (array_key_exists('stackTrace', $arr) && is_array($arr['stackTrace'])) {
throw new SchemaViolationException('Property \'stackTrace\' was array');
}
}
}
1 change: 1 addition & 0 deletions ruby/lib/cucumber/messages.deserializers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def self.from_h(hash)
self.new(
type: hash[:type],
message: hash[:message],
stack_trace: hash[:stackTrace],
)
end
end
Expand Down
9 changes: 8 additions & 1 deletion ruby/lib/cucumber/messages.dtos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,19 @@ class Exception < ::Cucumber::Messages::Message
##
attr_reader :message

##
# The stringified stack trace of the exception that caused this result
##
attr_reader :stack_trace

def initialize(
type: '',
message: nil
message: nil,
stack_trace: nil
)
@type = type
@message = message
@stack_trace = stack_trace
end
end

Expand Down

0 comments on commit 13dd4cc

Please sign in to comment.