Skip to content

Commit

Permalink
[wasm] Throw PlatformNotSupportedException instead of NotSupportedExc…
Browse files Browse the repository at this point in the history
…eption when starting threads/waiting on monitors. (#37604)

<!--
Thank you for your Pull Request!

If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.

Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->

Co-authored-by: vargaz <vargaz@users.noreply.github.com>
  • Loading branch information
monojenkins and vargaz authored Jun 8, 2020
1 parent b4a521d commit 3e56795
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mono/mono/metadata/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ mono_monitor_wait (MonoObjectHandle obj_handle, guint32 ms, MonoBoolean allow_in

#ifdef DISABLE_THREADS
if (ms == MONO_INFINITE_WAIT) {
mono_error_set_synchronization_lock (error, "Cannot wait on monitors on this runtime.");
mono_error_set_platform_not_supported (error, "Cannot wait on monitors on this runtime.");
return FALSE;
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/metadata/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,7 @@ ves_icall_System_Threading_Thread_Thread_internal (MonoThreadObjectHandle thread
MonoObject *start = MONO_HANDLE_RAW (start_handle);

#ifdef DISABLE_THREADS
mono_error_set_not_supported (error, "Cannot start threads on this runtime.");
mono_error_set_platform_not_supported (error, "Cannot start threads on this runtime.");
return FALSE;
#endif

Expand Down Expand Up @@ -6744,7 +6744,7 @@ ves_icall_System_Threading_Thread_StartInternal (MonoThreadObjectHandle thread_h
gboolean res;

#ifdef DISABLE_THREADS
mono_error_set_not_supported (error, "Cannot start threads on this runtime.");
mono_error_set_platform_not_supported (error, "Cannot start threads on this runtime.");
return;
#endif

Expand Down
5 changes: 5 additions & 0 deletions src/mono/mono/utils/mono-error-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ mono_error_set_cannot_unload_appdomain (MonoError *error, const char *message)
mono_error_set_generic_error (error, "System", "CannotUnloadAppDomainException", "%s", message);
}

static inline void
mono_error_set_platform_not_supported (MonoError *error, const char *message)
{
mono_error_set_generic_error (error, "System", "PlatformNotSupportedException", "%s", message);
}

MonoException*
mono_error_prepare_exception (MonoError *error, MonoError *error_out);
Expand Down

0 comments on commit 3e56795

Please sign in to comment.