Open Bug 1940512 Opened 1 month ago Updated 1 month ago

Improve TranslationsException in Translations Controller

Categories

(Fenix :: Translations, task, P3)

All
Android
task

Tracking

(Not tracked)

People

(Reporter: olivia, Unassigned)

Details

While working on Bug 1937842, I realized we sometimes wern't passing the exception reason from GeckoViewTranslations.sys.mjs on to the Translations Controller and on the TranslationsException.

Additionally, a few Translations Controller execptions are still Query Exceptions and not mapped to Translations Exceptions. It would be good to update that too.

This bug is to:

  • Update TranslationsException to include a message
  • Pass on JS message to TranslationsException
  • There are a few plain Query Exceptions expections that would be best mapped to TranslationsException, depending on how many, it might be good to fix them here or file a new bug
  • Check if any of these changes impact Fenix/AC. (They likely won't, it appears they are being wrapped into UnknownError.

Example expected TranslationsException update:

     public TranslationsException(final @Code int code) {
       this.code = code;
      this.message = null;
    }

    /**
     * Construct a [TranslationsException]
     *
     * @param code Error code the given exception corresponds to.
     * @param message Message or reasoning behind the error code.
     */
    public TranslationsException(final @Code int code, @Nullable final String message) {
      this.code = code;
      this.message = message;
     }

     /** Default error for unexpected issues. */

     /** {@link Code} that provides more information about this exception. */
     public final @Code int code;
    /** Exception message or reason */
     public final @Nullable String message;
 
     @Override
     public String toString() {
      if (DEBUG && message != null){
        return "TranslationsException: " + code + " Message: " + message;
      }
       return "TranslationsException: " + code;
     }
   }
...

On a mapped exception:
new TranslationsException(TranslationsException.ERROR_COULD_NOT_TRANSLATE, ((EventDispatcher.QueryException) exception).data.toString()));

These changes would improve GeckoView ergonomics more than anything else.

Severity: -- → N/A
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.