Skip to content

Commit

Permalink
refactor: improve error handling and logging in Movie deserialization
Browse files Browse the repository at this point in the history
Enhanced the deserialization error handling by adding detailed logging:
- Log buffer length and raw buffer data in hexadecimal format for better debugging.
- Switched to console.error for more appropriate error logging.
  • Loading branch information
Onyewuchi Emeka committed Aug 25, 2024
1 parent 2997cca commit 2a14949
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,14 @@ export class Movie {
}

try {
const { title, rating, description } = this.borshAccountSchema.decode(buffer)
return new Movie(title, rating, description)
} catch(error) {
console.log('Deserialization error:', error)
return null
const { title, rating, description } =
this.borshAccountSchema.decode(buffer);
return new Movie(title, rating, description);
} catch (e) {
console.error("Deserialization error:", e);
console.error("Buffer length:", buffer.length);
console.error("Buffer data:", buffer.toString("hex"));
return null;
}
}
}
Expand Down

0 comments on commit 2a14949

Please sign in to comment.