Skip to content

Commit

Permalink
fix(engine): Fix ignored errors
Browse files Browse the repository at this point in the history
So looks like all errors have an error_code key, the json['meta']['error'] was not working because it was a String instead of Map.
validating by error_code is the right way I guess, at least is working in my use case.
https://www.prisma.io/docs/reference/api-reference/error-reference#error-codes

Signed-off-by: Uriel <urychdz@hotmail.es>
  • Loading branch information
PeterMX committed Mar 27, 2023
1 parent 8d9290f commit fe8c89f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/universal_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ class UniversalEngine implements Engine {

/// Try throw an [PrismaException] from the [json].
void _tryThrowPrismaException(Map<String, dynamic> json) {
if (json['meta']?['error'] != null && json['meta']['error'] is Map) {
final exception =
GraphQLError.fromJson(json['meta']['error']).toException(this);
if (json['error_code'] != null && json['error_code'] is String && json['error_code'].isNotEmpty) {
final exception = GraphQLError.fromJson(json).toException(this);

logger.emit(Event.error, Payload(message: exception.message));
throw exception;
Expand Down

0 comments on commit fe8c89f

Please sign in to comment.