Added InvalidSnowflakeException.
[ci skip]
This commit is contained in:
parent
df19a08639
commit
f5cb6112a0
|
@ -27,6 +27,7 @@ part "src/ClientOptions.dart";
|
|||
part "src/internal/exceptions/MissingTokenError.dart";
|
||||
part "src/internal/exceptions/EmbedBuilderArgumentException.dart";
|
||||
part "src/internal/exceptions/InvalidShardException.dart";
|
||||
part "src/internal/exceptions/InvalidSnowflakeException.dart";
|
||||
|
||||
part "src/internal/shard/Shard.dart";
|
||||
part "src/internal/shard/ShardManager.dart";
|
||||
|
|
|
@ -23,7 +23,11 @@ class Snowflake implements Comparable<Snowflake> {
|
|||
if (id is int) {
|
||||
_id = id;
|
||||
} else {
|
||||
_id = int.parse(id.toString());
|
||||
try {
|
||||
_id = int.parse(id.toString());
|
||||
} on FormatException {
|
||||
throw InvalidSnowflakeException._new(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
part of nyxx;
|
||||
|
||||
/// Thrown when cannot convert provided data to [Snowflake]
|
||||
class InvalidSnowflakeException implements Exception {
|
||||
final dynamic _invalidSnowflake;
|
||||
|
||||
InvalidSnowflakeException._new(this._invalidSnowflake);
|
||||
|
||||
@override
|
||||
String toString() => "InvalidSnowflakeException: Cannot parse [$_invalidSnowflake] to Snowflake";
|
||||
}
|
Loading…
Reference in a new issue