Skip to content

Commit

Permalink
Throw distinct error for prohibitedInView methods
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrichina committed Oct 7, 2024
1 parent 5091782 commit a492556
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions json-rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ const handleError = async ({ ctx, blockHeight, error }) => {
case 'notImplemented':
await proxyJson(ctx);
return;
case 'prohibitedInView':
ctx.body = viewCallError({
id,
message: `wasm execution failed with error: HostError(ProhibitedInView { method_name: "${error.data.methodName}" })`,
});
return;
case 'panic':
case 'abort':
ctx.body = viewCallError({
Expand Down
3 changes: 1 addition & 2 deletions runtime/view-only.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const imports = (ctx) => {

const prohibitedInView = (name) => (...args) => {
debug('prohibitedInView', name, 'args', args);
// TODO: Shouldn't this use unique code which is not resulting in proxyJson?
throw new FastNEARError('notImplemented', 'method not available for view calls: ' + name, { methodName: name });
throw new FastNEARError('prohibitedInView', 'method not available for view calls: ' + name, { methodName: name });
};

const registers = {};
Expand Down

0 comments on commit a492556

Please sign in to comment.