Merge pull request #14607 from Snuffleupagus/wrapReason-unreachable
Simplify the `wrapReason` helper function
This commit is contained in:
		
						commit
						f782f5e5bb
					
				@ -21,7 +21,7 @@ import {
 | 
			
		||||
  PasswordException,
 | 
			
		||||
  UnexpectedResponseException,
 | 
			
		||||
  UnknownErrorException,
 | 
			
		||||
  warn,
 | 
			
		||||
  unreachable,
 | 
			
		||||
} from "./util.js";
 | 
			
		||||
 | 
			
		||||
const CallbackKind = {
 | 
			
		||||
@ -49,17 +49,10 @@ function wrapReason(reason) {
 | 
			
		||||
      (typeof reason === "object" && reason !== null)
 | 
			
		||||
    )
 | 
			
		||||
  ) {
 | 
			
		||||
    if (
 | 
			
		||||
      typeof PDFJSDev === "undefined" ||
 | 
			
		||||
      PDFJSDev.test("!PRODUCTION || TESTING")
 | 
			
		||||
    ) {
 | 
			
		||||
      throw new Error(
 | 
			
		||||
    unreachable(
 | 
			
		||||
      'wrapReason: Expected "reason" to be a (possibly cloned) Error.'
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
    warn('wrapReason: Expected "reason" to be a (possibly cloned) Error.');
 | 
			
		||||
    return reason;
 | 
			
		||||
  }
 | 
			
		||||
  switch (reason.name) {
 | 
			
		||||
    case "AbortException":
 | 
			
		||||
      return new AbortException(reason.message);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user